我怎么做的父子关系的渴望查询: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