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

Notifications

Announcements

No record found.

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

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    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

    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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans