У меня есть этот запрос EF
var r = (from cd in _context.CentoData
.Where(c =>
(string.IsNullOrEmpty(geneName) ? true : c.Gene == geneName) &&
(string.IsNullOrEmpty(codingEffect) ? true : c.CodingEffect == codingEffect) &&
(string.IsNullOrEmpty(zygosity) ? true : c.Zygosity == zygosity) &&
(string.IsNullOrEmpty(sex) ? true : c.Sex == sex) &&
(string.IsNullOrEmpty(clinicalStatement) ? true : c.ClinicalStatement == clinicalStatement) &&
(onsetAge == null ? true : c.AgeAtDiagnosisYearsMonths < onsetAge))
from gs in _context.GnomadSnv
.Where(g => g.Chromosome == cd.Chromosome &&
g.Position == cd.Position &&
g.Ref == cd.RefNt &&
g.Alt == cd.AltNt)
.DefaultIfEmpty()
select new resultType
{
name = cd.name,
AF = g.AF
}
И он хорошо работает. Но когда я включаю подзапрос Contains
, как показано ниже (строка 9), он выдает ошибку, в которой говорится:
«Не удалось связать многоэлементный идентификатор« c.Chromosome »».
patients
- список строк с десятками до сотен элементов.
var r = (from cd in _context.CentoData
.Where(c =>
(string.IsNullOrEmpty(geneName) ? true : c.Gene == geneName) &&
(string.IsNullOrEmpty(codingEffect) ? true : c.CodingEffect == codingEffect) &&
(string.IsNullOrEmpty(zygosity) ? true : c.Zygosity == zygosity) &&
(string.IsNullOrEmpty(sex) ? true : c.Sex == sex) &&
(string.IsNullOrEmpty(clinicalStatement) ? true : c.ClinicalStatement == clinicalStatement) &&
(onsetAge == null ? true : c.AgeAtDiagnosisYearsMonths < onsetAge) &&
(patients != null ? patients.Contains(c.RandomPatientId): true))
from gs in _context.GnomadSnv
.Where(g => g.Chromosome == cd.Chromosome &&
g.Position == cd.Position &&
g.Ref == cd.RefNt &&
g.Alt == cd.AltNt)
.DefaultIfEmpty()
select new resultType
{
name = cd.name,
AF = g.AF
}
Я что-то здесь упустил?