简体   繁体   English

是否可以在 Linq 或 Lambda 表达式中包含 Where 或 Any 表达式?

[英]Is it possible to have Where or Any expression inside Include in Linq or Lambda expression?

Something similar to this类似的东西

Ex前任

var temp = dbcontext.ModelA.include(x=>x.ModelB.where(...))
var temp = dbcontext.ModelA.include(x=>x.ModelB.Any(...))

Yes filtered includes are supported, but only as of EF Core 5.0, which would allow you to use Where .是的,支持过滤包含,但仅从 EF Core 5.0 开始,这将允许您使用Where

According to the docs:根据文档:

Supported operations are: Where , OrderBy , OrderByDescending , ThenBy , ThenByDescending , Skip , and Take .支持的操作有: WhereOrderByOrderByDescendingThenByThenByDescendingSkipTake

However, using Any directly does not make sense, because it returns bool rather than a subset of related entities.但是,直接使用Any没有意义,因为它返回bool而不是相关实体的子集。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM