views:

49

answers:

1

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)
);
+4  A: 

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));
Yuriy Faktorovich
Perfect. Thank you
Nicholas Mayne