.xxxxxx ?? v.Outer.Outer.xxxx)' 无法翻译 OrderByDescending with null conditional asp.net core 6

.xxxxxx ?? v.Outer.Outer.xxxx)' could not be translated OrderByDescending with null conditional asp.net core 6

    public virtual DateTime? LastModificationTime { get; set; }
    public virtual DateTime CreationTime { get; set; }

查询

await vulnerabilityMappingSelect
      .OrderByDescending(x => x.LastModificationTime ?? x.CreationTime)
      .PageBy(input).ToListAsync();

尝试过滤,如果 LastModificationTime 有值,则用 LastModificationTime 排序,否则用 CreationTime

排序

获取异常无法翻译如下

The LINQ expression 'DbSet<VulnerabilityMappingTemplate>()
    .Where(v => __ef_filter__p_0 || !(((ISoftDelete)v).IsDeleted) && __ef_filter__p_1 || (int?)((IMustHaveTenant)v).TenantId == __ef_filter__CurrentTenantId_2)
    .Where(v => v.TenantId == __AbpSession_TenantId_Value_0)
    .Join(
        inner: DbSet<SourceType>()
            .Where(s => __ef_filter__p_3 || !(((ISoftDelete)s).IsDeleted) && __ef_filter__p_4 || ((IMayHaveTenant)s).TenantId == __ef_filter__CurrentTenantId_5), 
        outerKeySelector: v => EF.Property<int?>(v, "SourceTypeId"), 
        innerKeySelector: s => EF.Property<int?>(s, "Id"), 
        resultSelector: (o, i) => new TransparentIdentifier<VulnerabilityMappingTemplate, SourceType>(
            Outer = o, 
            Inner = i
        ))
    .Join(
        inner: DbSet<SourceTool>()
            .Where(s0 => __ef_filter__p_6 || !(((ISoftDelete)s0).IsDeleted) && __ef_filter__p_7 || ((IMayHaveTenant)s0).TenantId == __ef_filter__CurrentTenantId_8), 
        outerKeySelector: v => EF.Property<int?>(v.Outer, "SourceToolId"), 
        innerKeySelector: s0 => EF.Property<int?>(s0, "Id"), 
        resultSelector: (o, i) => new TransparentIdentifier<TransparentIdentifier<VulnerabilityMappingTemplate, SourceType>, SourceTool>(
            Outer = o, 
            Inner = i
        ))
    .OrderByDescending(v => new VulnerabilityMappingTemplate{ 
        Id = v.Outer.Outer.Id, 
        TemplateName = v.Outer.Outer.TemplateName, 
        SourceType = v.Outer.Inner, 
        SourceTool = v.Inner, 
        VulnerabilityFieldMapping = MaterializeCollectionNavigation(
            Navigation: VulnerabilityMappingTemplate.VulnerabilityFieldMapping,
            subquery: DbSet<VulnerabilityFieldMapping>()
                .Where(v0 => __ef_filter__p_9 || !(((ISoftDelete)v0).IsDeleted) && __ef_filter__p_10 || (int?)((IMustHaveTenant)v0).TenantId == __ef_filter__CurrentTenantId_11)
                .Where(v0 => EF.Property<long?>(v.Outer.Outer, "Id") != null && object.Equals(
                    objA: (object)EF.Property<long?>(v.Outer.Outer, "Id"), 
                    objB: (object)EF.Property<long?>(v0, "VulnerabilityMappingTemplateId")))), 
        LastModifierUserId = v.Outer.Outer.LastModifierUserId, 
        CreatorUserId = v.Outer.Outer.CreatorUserId, 
        CreationTime = v.Outer.Outer.CreationTime 
    }
    .LastModificationTime ?? v.Outer.Outer.CreationTime)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.

LastModificationTime 没有定义投影的问题。您在 VulnerabilityMappingTemplate.

的初始化中错过了它