is case, the GroupBy operator doesn't translate directly to a ` GROUP BY
` clause in the SQL, but instead, EF Core creates the groupings after the
results are returned from the server.

##  Left Join

While Left Join isn't a LINQ operator, relational databases have the concept
of a Left Join which is frequently used in queries. A particular pattern in
LINQ queries gives the same result as a ` LEFT JOIN ` on the server. EF Core
identifies such patterns and generates the equivalent ` LEFT JOIN ` on the
server side. The pattern involves creating a GroupJoin between both the data
sources and then flattening out the grouping by using the SelectMany operator
with DefaultIfEmpty on the grouping source to match null when the inner
doesn't have a related element. The following example shows what that pattern
looks like and what it generates.

    
    
    var query = from b in context.Set<Blog>()
                join p in context.Set<Post>()
                    on b.BlogId equals p.BlogId into grouping
                from p in grouping.DefaultIfEmpty()
                select new { b, p };
    
    
    
    SELECT [b].[BlogId], [b].[OwnerId], [b].[Rating], [b].[Url], [p].[PostId], [p].[AuthorId], [p].[BlogId], [p].[Content], [p].[Rating], [p].[Title]
    FROM [Blogs] AS [b]
    LEFT JOIN [Posts] AS [p] ON [b].[BlogId] = [p].[BlogId]
    

The above pattern creates a complex structure in the expression tree. Because
of that, EF Core requires you to flatten out the grouping results of the
GroupJoin operator in a step immediately following the operator. Even if the
GroupJoin-DefaultIfEmpty-SelectMany is used but in a different pattern, we may
not identify it as a Left Join.

Collaborate with us on GitHub

The source for this content can be found on GitHub, where you can also create
and review issues and pull requests. For more information, see [ our
contributor guide
](https://learn.microsoft.com/contribute/content/dotnet/dotnet-contribute) .

![](https://learn.microsoft.com/media/logos/logo_net.svg)
![](https://learn.microsoft.com/media/logos/logo_net.svg)

.NET

[ Open a documentation issue  ]() [ Provide product feedback
](https://github.com/dotnet/efcore/issues/new/choose)

##  Feedback

Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the
feedback mechanism for content and replacing it with a new feedback system.
For more information see: [ https://aka.ms/ContentUserFeedback
](https://aka.ms/ContentUserFeedback) .

Submit and view feedback for

[ This product  ](https://github.com/dotnet/efcore/issues/new/choose) This
page

[ View all page feedback
](https://github.com/dotnet/EntityFramework.Docs/issues)

* * *

##  Additional resources

[ California Consumer Privacy Act (CCPA) Opt-Out Icon  Your Privacy Choices
](https://aka.ms/yourcaliforniaprivacychoices)

Theme

  * Light 
  * Dark 
  * High contrast 

  *   * [ Previous Versions ](/en-us/previous-versions/)
  * [ Blog ](https://techcommunity.microsoft.com/t5/microsoft-learn-blog/bg-p/MicrosoftLearnBlog)
  * [ Contribute ](/en-us/contribute/)
  * [ Privacy ](https://go.microsoft.com/fwlink/?LinkId=521839)
  * [ Terms of Use ](/en-us/legal/termsofuse)
  * [ Trademarks ](https://www.microsoft.com/legal/intellectualproperty/Trademarks/)
  * © Microsoft 2024 

##  Additional resources

###  In this article

[ California Consumer Privacy Act (CCPA) Opt-Out Icon  Your Privacy Choices
](https://aka.ms/yourcaliforniaprivacychoices)

Theme

  * Light 
  * Dark 
  * High contrast 

  *   * [ Previous Versions ](/en-us/previous-versions/)
  * [ Blog ](https://techcommunity.microsoft.com/t5/microsoft-learn-blog/bg-p/MicrosoftLearnBlog)
  * [ Contribute ](/en-us/contribute/)
  * [ Privacy ](https://go.microsoft.com/fwlink/?LinkId=521839)
  * [ Terms of Use ](/en-us/legal/termsofuse)
  * [ Trademarks ](https://www.microsoft.com/legal/intellectualproperty/Trademarks/)
  * © Microsoft 2024