开发者

L2S querying child objects from parent (in 1-many relationship)

开发者 https://www.devze.com 2023-02-25 03:13 出处:网络
var obj = f开发者_高级运维rom 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= En
var obj = f开发者_高级运维rom 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;

I need to maintain the returned query as r i.e. IEnumerable


If I've understood your question right, are looking for something like this

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


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

精彩评论

暂无评论...
验证码 换一张
取 消