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

Announcements

No record found.

News and Announcements icon
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans