Is there a way to filter LoadWith in Linq
I currently have ReportCategory and Reports tables. I want to get all categories, and then I only want to download active reports.
This is what I still have.
DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith<ReportCategory>(report => report.Reports); db.LoadOptions = dlo; var categories = from c in db.ReportCategory where c.InUse == true select c;
It returns all active categories and all reports for each category, as expected, but I do not need all reports, I only need those that are marked as InUse.
So I tried this ...
dlo.LoadWith<ReportCategory>(report => report.Reports.Where(r => r.InUse == true));
but I get the following error.
InvalidOperationException: the specified expression must be of the form pA, where p is a parameter, and A is an element of a property or field.
Is there a way to do this with LoadWith, or just move on to using a connection?
source share