【发布时间】:2021-07-12 04:17:14
【问题描述】:
我有一个公司实体与订单实体具有一对多关系。
订单可以是匿名的,在这种情况下,查询订单时不应加载相关公司。
当前格式创建一个 IQueryable,然后向其添加过滤器,如下所示:
IQueryable<Order> queryable = ...
...
if (includeCompany is not null and true)
{
queryable = queryable.Include(o => o.Company);
}
if (includeAddress is not null and true)
...
我能否将包含条件设置为在单个查询中使用订单的 isAnonymous 布尔值,以便仅包含非匿名订单的公司实体?
【问题讨论】:
标签: linq .net-core entity-framework-core