From the additional information you have provided it seems that the most appropriate solution for you would be to populate your search listbox with one query, for examples:
var customers = context.Customers.Where(x=>x.FirstName == firstName);
Once you have the list of customers that satisfy a criteria and would like to display the details panel with additional information, you could create a second query selecting the latest invoice for a customer (querying by the customer's primary key) like so:
var latestInvoice = customers.First(x=>x.Id == selectedCustomerId).Invoices.FirstOrDefault();
Writing your queries this way (avoiding projection in anonymous types) would help you minimize the database queries and traffic.
In case you have a desktop application and have a read-only search-details form (no transactions are expected
) it would be feasible to use a single context on that page this way taking further advantage of the Telerik Data Access Level One Cache
. On the other hand if you have a web application and your context is disposed per request it is possible to enable the Telerik Data Access Second Level Cache
gaining additional performance boast. More information on how to work with the cache and what benefits it provides could be found in this documentation article
I hope this helps you. Do not hesitate to contact us with any further questions.
OpenAccess ORM is now Telerik Data Access
. For more information on the new names, please, check out the Telerik Product Map