Notifications
Announcements
No record found.
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?
*This post is locked for comments
I think you request ToList() too eraly. After DefaultIfEmpty() you should have Select new {...} then put some brackets and put at the end ToList(). Hope it works.
delete ToList() and will be working
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2