linq2sql left join with "multiselect"
- by just_azho
Hi, folks
I'm trying to achieve following by linq2sql, but not successful.
I've Member and Reference tables. DB is design in such a manner that Member can have multiple (=0) References. What I want as a result of query is, list (rows) of members, where all references of the member are "collected" in one column.
What I had achieved is following query, but for this one there exist a row for each Reference.
var refs = (from m in db.Members
join
r in db.References on m.PID equals r.PID into g
from o in g.DefaultIfEmpty()
select new
{
member = m,
name = (o == null ? "" : o.NameSurname)
});
I feel I need to insert SelectMany somewher :)
Could you please give hints on achieving the goal?