I’m trying to get data from two tables. Todo_Lists and Todo_Items. I manged to join the two like this:
from list in dataContext.Todo_Lists
from item in dataContext.Todo_List_Items
where list.UserID == userID && list.ListID == item.ListID
select new
{
ListID = list.ListID,
ListName = list.ListName,
ItemID = item.ItemID,
ItemName = item.ItemName
};
That’s all good in the hood if I just want the lists with Items on them. But I need to return all the lists and where there are Items I need them to be joined in.
Thankfull for any information.
sounds like a left outer join: (untested)
you’ll probably need to cast the nulls for the conditional to work – I left it out cos I don’t know the type. See here for more info on left outer joins using linq.