While I trying to update the following LINQ query for getting data from two tables in CRM using LEFT JOIN, It shows following error:
(I am using CRM SDK 2016).
The 'GroupJoin' operation must be followed by a 'SelectMany' operation where the collection selector is invoking the 'DefaultIfEmpty' method.
Query:
from b in FirstTable join itbl in SecondTable
on b.Id equals itbl.Id into ITable
from i in ITable.DefaultIfEmpty().ToList()
Error details:
Source=Microsoft.Xrm.Sdk
StackTrace:
at Microsoft.Xrm.Sdk.Linq.QueryProvider.ThrowException(Exception exception)
at Microsoft.Xrm.Sdk.Linq.QueryProvider.TranslateGroupJoin(QueryExpression qe, IList`1 methods, Int32& i, Projection& projection, List`1& linkLookups)
at Microsoft.Xrm.Sdk.Linq.QueryProvider.GetQueryExpression(Expression expression, Boolean& throwIfSequenceIsEmpty, Boolean& throwIfSequenceNotSingle, Projection& projection, NavigationSource& source, List`1& linkLookups)
at Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute[TElement](Expression expression)
at Microsoft.Xrm.Sdk.Linq.QueryProvider.GetEnumerator[TElement](Expression expression)
at Microsoft.Xrm.Sdk.Linq.Query`1.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
Any help?