开发者

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));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜