EF核心,任何人都无法翻译,并且将在本地进行评估



我有一个过程,它返回了我需要的实体ID。

(我决定创建此过程,因为应该返回最终用户的实体是由相关实体过滤的,但是EF Core不支持相关实体的过滤(。

然后,我想使用这些ID来获取实体,我需要女巫与他们相关的实体。

我正在使用 Any operator. In my opinion it should generate query like this: ,其中ID中的ID(1,2,3,4 ....(

相反,它返回警告:

的信息

无法翻译任何条款,并将在本地评估

我如何解决它?

我的代码下面:

var assocsIds = await _context.Assoc.AsNoTracking()
.FromSql($"exec {SqlProcedures.GetAssocsForIndexProc} {query.IndexMviId}, {query.FilterByGroupId}")
.ToListAsync()
var productAssocs = await _context.Assoc
    .Where(x => assocsIds.Any(z => z.Id == x.Id))
    .Include(x => x.Attribute)
    .ThenInclude(x => x.Translation)
    .Include(x => x.Option)
    .ThenInclude(x => x.Translation)
    .Include(x => x.Mvi)
    .ThenInclude(x => x.Translation)
    .AsNoTracking()
    .ToListAsync()
;

您是否可以首先从 coossids 中选择" ID" S,然后尝试以下?

var productAssocs = await _context.Assoc
            .Where(x => yourIdsList.Contains(x.Id))
            .Include(x => x.Attribute)
            .ThenInclude(x => x.Translation)
            .Include(x => x.Option)
            .ThenInclude(x => x.Translation)
            .Include(x => x.Mvi)
            .ThenInclude(x => x.Translation)
            .AsNoTracking()
            .ToListAsync();

相关内容

最新更新