I have a GetOrder (int OrderID) method that launches a LINQ query and returns an order. There are many properties of an object that can be preloaded (i.e. with Include ()) in a request, for example. DeliveryMethod, Customer, CustomerBillingAddress, etc. I want the method to allow the caller to specify which properties are preloaded using the method arguments. Needless to say, I don't want to explicitly write out every possible LINQ query in this method.
Thus, you can program the main query and then add. Turns on dynamically, for example.
if(PreLoadCustomer) query.Include("Customer")
Note. I know that there is lazy loading - this will not work - related objects should be available immediately.
thanks
source share