开发者

Linq to Entities : How to filter master table rows based on child rows properties

开发者 https://www.devze.com 2022-12-20 22:58 出处:网络
I have a master table Person and a detail table Events I need to filter master table rows based on child row property Some开发者_如何学运维Id.

I have a master table Person and a detail table Events

I need to filter master table rows based on child row property Some开发者_如何学运维Id.

Could anyone please show me how to do it ?

Thanks in advance!


This works!

var q = from p in db.Persons
        join ev in db.Events on p.Id equals ev.PersonId
        where ev.SomeId == 4
        select p;


var q = db.Events.Where(p=>p.SomeId == 4).Select(p=>p.Person).Distinct();
0

精彩评论

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