Enhance this LINQ query for readability and performance?
I'm not the greatest with LINQ, but I'm trying to retrieve all the ModuleAvailabilities
where the academicYear
is the current year.
Are there any improvements to be made here?
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)
);
I think you mean
pathway.PathwayFoundationModule.Attach(
pathway.PathwayFoundationModule.CreateSourceQuery()
.Include("Module")
.Include("Module.ModuleAvailabilities.Location")
.Where(o => o.Module.ModuleAvailabilities
.Any(x => x.AcademicYear == academicYear.Current));
精彩评论