加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 实体框架6 – 选择孩子平等的父母

发布时间:2020-12-16 00:11:06 所属栏目:百科 来源:网络整理
导读:我只需要Parent对象.在SQL中,这很简单: select distinct * from parent join child on child.ParentID = Parent.ID where child.playssoccer = true; 在实体框架6中,这似乎将原子分裂给我. 我需要新的p = parent.children.playssoccer = true的父级. 如何从
我只需要Parent对象.在SQL中,这很简单:

select distinct * from parent 
join child on child.ParentID = Parent.ID 
where child.playssoccer = true;

在实体框架6中,这似乎将原子分裂给我.

我需要新的p => parent.children.playssoccer = true的父级.

如何从类似的EF6 DBContext中获取足球父母?

解决方法

from p in context.Parents
where p.Children.Any(c => c.PlaySoccer == true)
select p

这假设您希望父母至少有一个孩子踢足球.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读