27 November 2026

EF Core 11 FullJoin for Beginners: Match Students and Scholarships with LINQ

  Asp.Net CS By Example       27 November 2026

In earlier versions of Entity Framework Core, writing a full outer join in LINQ was awkward—you had to combine GroupJoin, SelectMany, and DefaultIfEmpty or stitch two separate queries together. With .NET 11 and EF Core 11, LINQ includes a native FullJoin operator that translates straight into a database FULL OUTER JOIN. In this tutorial, you will match student profiles against scholarship awards so you can see matched records and gaps on both sides.

How FullJoin keeps both sides

Students (Left) + Scholarships (Right) → Matched Pairs + Unmatched Left & Right Rows (null)

When Should You Use FullJoin?

An inner join drops unmatched rows from both tables, and a left join only keeps unmatched rows from the left table. Use FullJoin when you need a complete reconciliation view—for example, finding students without scholarships and scholarship awards whose student ID does not match an active student record.

1. Define the Entities and Query with FullJoin

Suppose your DbContext has DbSet<Student> Students and DbSet<Scholarship> Scholarships. Pass the inner sequence, outer key selector, inner key selector, and result projection to FullJoin:

using Microsoft.EntityFrameworkCore;

public record Student(int Id, string Name);
public record Scholarship(int Id, int StudentId, string Title);

// Inside an async method using your EF Core 11 DbContext:
var reconciliation = await context.Students
    .FullJoin(
        context.Scholarships,
        student => student.Id,
        award => award.StudentId,
        (student, award) => new
        {
            StudentName = student != null ? student.Name : "Missing Student Record",
            AwardTitle = award != null ? award.Title : "No Award Assigned",
            MatchStatus = (student, award) switch
            {
                (not null, not null) => "Matched",
                (not null, null) => "Student Only",
                (null, not null) => "Award Only",
                _ => "Unknown"
            }
        })
    .ToListAsync();

foreach (var row in reconciliation)
{
    Console.WriteLine($"{row.StudentName} | {row.AwardTitle} | {row.MatchStatus}");
}

2. Check the Generated SQL Pattern

Because EF Core 11 understands FullJoin on IQueryable, the database performs the join in a single SQL query instead of downloading both tables into memory:

SELECT
    CASE WHEN [s].[Id] IS NOT NULL THEN [s].[Name] ELSE N'Missing Student Record' END AS [StudentName],
    CASE WHEN [a].[Id] IS NOT NULL THEN [a].[Title] ELSE N'No Award Assigned' END AS [AwardTitle]
FROM [Students] AS [s]
FULL OUTER JOIN [Scholarships] AS [a] ON [s].[Id] = [a].[StudentId];

Note: Make sure your database provider supports FULL OUTER JOIN (SQL Server, PostgreSQL, and SQLite 3.39+ support it natively).

Understand the Important Rules

  1. Handle nulls on both sides: Either student or award can be null in the result selector, so always guard property reads with null checks or C# pattern matching.
  2. Keep projections simple: Project the exact columns or status labels you need inside the result selector so EF Core generates clean, fast SQL.

Practice

  1. Filter the FullJoin result with .Where(x => x.MatchStatus != "Matched") so your report lists only exceptions that need review.
  2. Compare the output of LeftJoin vs FullJoin on the same sample tables when one scholarship points to a deleted StudentId.
  3. Combine FullJoin with an OrderBy(x => x.MatchStatus) clause so unmatched records appear at the top of the report.

Continue learning: .NET Core and ASP.NET Core: Student Learning Path | C# Tutorials and Examples.

References: What's New in EF Core (Microsoft Learn).

logoblog

Thanks for reading EF Core 11 FullJoin for Beginners: Match Students and Scholarships with LINQ

Previous
« Prev Post

No comments:

Post a Comment

Please do not enter any spam link in the comment box.