I have the following LINQ statement, and I’m finding that it’s not running as quickly as I’d like. Are there other variations that run faster, or is there another way to do it that is faster?
var products = session.Products.Where(x => x.Supplier.Address.State == "HI").ToList();
What you didn’t state is that this was in a blog post for a specific LINQ provider. Let’s put it in context:
It’s not the call to
ToListwhich “usually spells trouble for performance” – it’s the fact that you’re doing a “deep graph query” in an object database. Yes, you’re then fetching all the results into memory, but it’s the nature of the store which is the cause for concern here.