L2S从父级查询子对象(1-many关系)

时间:2011-04-13 15:59:43

标签: .net linq-to-sql

var obj = from r in db.ParentTables
          where r.ChildTable.Count > 0 // &&  How can we get the Child table data by parsing value by query string.? for eg: r.ChildTable.Language= English
          select r;

我需要将返回的查询维护为r,即IEnumerable

2 个答案:

答案 0 :(得分:1)

如果我理解你的问题,正在寻找类似的东西

var obj = from r in db.ParentTables
          where r.ChildTable.Any(c => c.Language = "English")
          select r;

答案 1 :(得分:0)

var obj = from r in db.ParentTables
          where r.ChildTable.Any(c => c.Count() > 0 && c.Language == "English")
          select r;