I have compiled queries for both, the main entity customer
and for related entities(orders).
var customer = MyService.GetCustomer<Customer>().where(c => c.Id == fooId).ToList();
var customerOrders = MyService.GetOrders<Order>().where(o => o.CustomerId == fooId && o.IsActive).ToList();
But I think I can get all orders through navigation properties instead of compiled query calls since customer
is already loaded in memory by the code below:
var customerOrders = customer.Orders.where(o => o.IsActive).ToList(); // I didn't do filter further more
But when I measure the timings I couldn't find any considerable amount of difference (The DB has 500 customers and 4000 orders. And every particular customer has 30 active orders and around 400 inactive orders).
Which one of these two would have a better performance?
I could not fully understand this related question