필요한 엔티티의 ID를 반환하는 프로 시저가 있습니다.
최종 사용자에게 returend해야하는 엔티티는 관련 엔티티에 의해 필터링되지만 ef core는 관련 엔티티에 의한 필터링을 지원하지 않으므로이 절차를 작성하기로 결정했습니다.
그런 다음이 ID를 사용하여 관련 엔터티가 필요한 엔터티를 가져 오려고합니다.
"모든"연산자를 사용하고 있습니다. 내 의견으로는이 쿼리를 생성해야합니다 : "어디에서 id (1,2,3,4 ....)"하지만 그것은, 내가 원하는 것처럼 작동하지 않는 것 같습니다.
대신 "Any 절을 번역 할 수 없으며 로컬로 평가됩니다"라는 정보와 함께 경고를 반환합니다.
내가 어떻게 고칠 수 있니?
나 아래 코드 :
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()
;
먼저 assocsIds 에서 "Id"를 다른 변수로 선택하고 다음을 시도해 볼 수 있습니까?
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();