Skip to content

Instantly share code, notes, and snippets.

@grishin
Created January 25, 2014 15:36
Show Gist options
  • Select an option

  • Save grishin/8618159 to your computer and use it in GitHub Desktop.

Select an option

Save grishin/8618159 to your computer and use it in GitHub Desktop.
How to JOIN multiple tables with multiple ON conditions in LINQ
from project in _db.Projects
join typeOfficial in _db.GuidContents on (short?)project.TypeOfficial equals typeOfficial.Value into TtypeOfficial
from typeOfficial in TtypeOfficial.DefaultIfEmpty()
where typeOfficial.Guid == 1
join typePanel in _db.GuidContents on (short?)project.TypePanel equals typePanel.Value into TtypePanel
from typePanel in TtypePanel.DefaultIfEmpty()
where typePanel.Guid == 2
join status in _db.GuidContents on (short?)project.StatusId equals status.Value into TStatus
from status in TStatus.DefaultIfEmpty()
where status.Guid == 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment