web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM Left Join issue

(0) ShareShare
ReportReport
Posted on by

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

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: CRM Left Join issue

    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.

  • Community Member Profile Picture
    on at
    RE: CRM Left Join issue

    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.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans