Assume the following 2 tables:
Customers - 1:n - Orders
In a datagridview i want to display a list with seleted fields of the Customer, and a field indicating the number of Orders related to that customer.
This number of Orders is determined in the View by: calling Orders.Count on the item object (being a type of Customer, from my Model.Customers)
The moment this line is rendered, LLBGen performs a SELECT * FROM Orders where CustomerID=x on the database.
Offcourse i can add a prefetchpath to the Customer collection, but that retrieves too much data.
Is there a way to add a prefetch for an aggregate only?
something like:
MyPrefetchPath.Add(new FieldExpression(OrderFields.Somefield, Count))
Or are there better ways to do this in general.
(I don't want to use a fieldresultset, because i need a strongly typed entitycollection, and i don't want to run a GetDbCount() on each item in the View, because i think that would break the 'separation of concerns' principle.)