I have the following type of situation:
TABLE Customers (
CustomerID int,
etc... )
TABLE Orders (
OrderID int,
CustomerID int,
Active bit,
etc... )
I am using this in an ASP.NET MVC web application using Linq-to-Entities. I want to select all Customers and populate the Customer.Orders navigational property, and should only be populated with orders where Active==true
.
I've seen other questions that point to DataLoadOptions.AssociateWith
, but it appears I can't use that in ASP.NET. I've also seen this article, but it appears I would need to be calling CreateSourceQuery() in my view as I enumerate through Customers. This is possible, I suppose, but seems to be breaking MVC paradigm.
This seems to be a similar situation to "Filter child collection using a child collection of the child" except I need a solution for Linq-to-Entities instead of NHibernate. Thanks!