EF 3.1 LINQ表达式无法翻译虚拟实体包含

时间:2020-09-29 13:56:29

标签: asp.net-core entity-framework-core

我正在尝试使用以下代码过滤一些记录:

return base.CreateFilteredQuery(input)
            .WhereIf(input.OrganisationUnitId > 0, t => t.Records.Any(x => input.OrganisationUnitId == x.Record.OrganisationUnitId))
            .WhereIf(!input.Term.IsNullOrEmpty(), w => w.CreatorUser.FullName.Contains(input.Term));

但是我收到最近的“经典”错误:

.LeftJoin(
    outer: DbSet<User>
        .Where(u => __ef_filter__p_8 || !(((ISoftDelete)u).IsDeleted) && __ef_filter__p_9 || ((IMayHaveTenant)u).TenantId == __ef_filter__CurrentTenantId_10), 
    inner: p => EF.Property<Nullable<long>>(p, "CreatorUserId"), 
    outerKeySelector: u => EF.Property<Nullable<long>>(u, "Id"), 
    innerKeySelector: (o, i) => new TransparentIdentifier<PrintJob, User>(
        Outer = o, 
        Inner = i
    ))
.Where(p => p.Inner.FullName.Contains(__input_Term_1))' could not be translated.

我知道w.Status.Contains(input.Term)可以正常工作,所以我假设它不喜欢它的CreatorUser子实体。我打算对任何子实体运行查询吗?

0 个答案:

没有答案