我怎麼做的父子關係的渴望查詢:LINQ查詢 - 排序和過濾的渴望如何獲取
- 過濾器兒童領域
- 各種各樣雙方父母和孩子
- 返回列表或父母與孩子預填充
如果我嘗試
from p in _context.Parents.Include("children")
join c in _context.childrenon p.Id equals c.ParentId
where d.DeletedDate == null
orderby p.Name ascending, c.Name
select p
然後我得到的父對象回來,但每個家長都有NULL兒童
,如果我嘗試
from p in _context.Parents.Include("children")
orderby p.Name ascending
select p
查詢返回所有的父母和孩子,但他們不過濾或排序。
,我想回去的結果是IEnumerable<Parent>
即
Parent[0].name = "foo"
Parent[0].children = IEnumerable<Child>
Parent[1].name = "bar"
Parent[1].children = IEnumerable<Child>
我想每個家長可能爲零或更多的孩子。父母有多個孩子時,預期的產出是多少? – tvanfosson 2011-03-16 12:12:38
@tvanfosson我已更新我的問題與此信息 – Daveo 2011-03-16 12:18:06