One way for doing so is:
var parent = from p in db.tblParents where p.PrimaryKey == 1
select new {
Parent = p,
Children = p.tblChildren.Where(c => c.IsActive == true)
}.ToList();
However, you might not like the idea to return an anonymous type, then I would suggest to code it this way:
var parent = (from p in db.tblParents where p.PrimaryKey == 1).Single();
var childrens = ctx.Contacts.Where(c => c.ParentID == 1 && c.IsActive == true);
foreach (var child in childrens) {
parent.tblChildren.Add(child);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…