Skip to content

Outer join in LINQ: retarget net10.0, add LeftJoin and RightJoin examples - #2226

Open
vladimir-pecanac-main wants to merge 1 commit into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/109720-csharp-outer-join-linq
Open

vladimir-pecanac-main wants to merge 1 commit into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/109720-csharp-outer-join-linq

Conversation

@vladimir-pecanac-main

Copy link
Copy Markdown
Collaborator

Sample update for "How to Create an Outer Join in LINQ" (code-maze.com/csharp-outer-join-linq/). This PR touches only csharp-linq/HowToCreateAnOuterJoinInLINQLeftAndRight.

Changes:

  • Both projects retargeted from net8.0 to net10.0.
  • Test packages: Microsoft.NET.Test.Sdk 17.6.0 to 18.10.1, xunit 2.4.2 to 2.9.3, xunit.runner.visualstudio 2.4.5 to 4.0.0, coverlet.collector 6.0.0 to 10.0.1.
  • Utilities.cs: new PerformLeftJoinWithLeftJoinMethod and PerformRightJoinWithRightJoinMethod, using the Enumerable.LeftJoin and Enumerable.RightJoin operators that .NET 10 added to System.Linq.
  • Two new xunit tests for those methods; the project goes from 8 tests to 10.
  • SongWithAuthorComparer: Equals returns the comparison directly instead of an if statement around it, and GetHashCode uses HashCode.Combine(obj.Title, obj.AuthorName) so it hashes both properties Equals compares.
  • Program.cs prints the two new joins after the existing method syntax sections.

Package versions were re-queried on NuGet on 2026-09-23. Microsoft.NET.Test.Sdk is 18.10.1 today, one patch above the 18.10.0 the batch plan named, so 18.10.1 is what this PR uses. The other three match the plan.

Verified locally on SDK 10.0.302, runtime Microsoft.NETCore.App 10.0.10: dotnet build -c Release with 0 warnings and 0 errors, dotnet test with 10 of 10 passing, and dotnet list package --vulnerable --include-transitive clean on both projects. The console output of the existing sections is unchanged.

…ples

- Retarget both projects from net8.0 to net10.0.
- Bump test packages: Microsoft.NET.Test.Sdk 18.10.1, xunit 2.9.3,
  xunit.runner.visualstudio 4.0.0, coverlet.collector 10.0.1.
- Add PerformLeftJoinWithLeftJoinMethod and PerformRightJoinWithRightJoinMethod
  using the .NET 10 Enumerable.LeftJoin and Enumerable.RightJoin operators.
- Add two tests for the new methods (8 tests become 10).
- SongWithAuthorComparer: Equals returns the expression directly, and
  GetHashCode combines Title and AuthorName with HashCode.Combine.
- Program.cs prints the two new joins.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant