我不是LINQ的最佳人选,但我正在尝试检索ModuleAvailabilities
当前年份的所有academicYear
。
这里有什么改进吗?
pathway.PathwayFoundationModule.Attach(
pathway.PathwayFoundationModule.CreateSourceQuery()
.Include("Module")
.Include("Module.ModuleAvailabilities.Location")
.Where(o => o.Module.ModuleAvailabilities
.Where(x => x.AcademicYear == academicYear.Current)
.Count() >= 0)
);
答案 0 :(得分:5)
我认为你的意思是
pathway.PathwayFoundationModule.Attach(
pathway.PathwayFoundationModule.CreateSourceQuery()
.Include("Module")
.Include("Module.ModuleAvailabilities.Location")
.Where(o => o.Module.ModuleAvailabilities
.Any(x => x.AcademicYear == academicYear.Current));