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

c# – 使用linq查询集合的子集合

发布时间:2020-12-15 06:42:43 所属栏目:百科 来源:网络整理
导读:我有一个产品的集合,每个产品对象都有它自己的Product Images集合.每个ProductImage对象都有一个IsMainImage bool字段.我很难建立一个这样的Linq查询: select products.productimages.imagename where products.productid == 1 and product.productimages.i
我有一个产品的集合,每个产品对象都有它自己的Product Images集合.每个ProductImage对象都有一个IsMainImage bool字段.我很难建立一个这样的Linq查询:
select products.productimages.imagename where products.productid == 1 and     
product.productimages.ismainimage == true

任何人都可以帮助我弄清楚这一点,指出一个在线资源,我可以学习如何编写这样的linq查询,或者两者兼而有之?

感谢您的帮助!

解决方法

尝试像
from product in products
where product.productid == 1
from image in product.productimages
where image.ismainimage
select image.imagename

我也找到了这个可能包含您的信息的101 linq queries的这个列表.

(编辑:李大同)

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

    推荐文章
      热点阅读