I am trying to implement an outer join on this kind of query for the p.Person table.
How would I do this?
This example is taken from http://ashishware.com/DSLinqExample.shtml
var onlyinfo = p.Person
.Where(n => n.FirstName.Contains('a'))
.Join(p.PersonInfo,
n => n.PersonId,
m => m.PersonId,
(n, m) => m)
.ToArray<Persons.PersonInfoRow>();
Normally left joins in LINQ are modelled with group joins, sometimes in conjunction with
DefaultIfEmptyandSelectMany:That will give a sequence of pairs (n, m) where
nis the entry fromp.Personandmis the entry fromp.PersonInfo, butmwill be null if there are no matches.(It’s completely untested, btw – but should give you the idea anyway 🙂