簡體   English   中英

.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的初始化中錯過了它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM