none
Multiple context query. RRS feed

  • Question

  • This seems to be a common problem with EF. I would like to query with multiple contexts. For example I have an orders context and a catalog context. I would like to return all the orders that meet a certain criteria in the catalog context. I have seen one suggestion for getting data out of multiple context that gets all of the data in memory (a list) then uses that list as part of the query in the "other" context. The problem is that this is terribly inefficient (memory wise). Say I have a million orders and each order has an EntityCollection<T> that represents the individual items ordered.  So I build this huge list of all of the orders (assuming that it will fit in memory). Then order by order I check the items in the catalog for a match. If a match is found then I either yield the order or put this order in another list of results. I guess there isn't a good solution for queries and multiple contexts with EF yet? If I put all the entities in one context this results in one connection string. Because of varies environmental issues (replication being foremost) many of the databases reside on different servers in QA and Production. Whereas in DEV the databases are all on one server so one connection string works fine. But if I want to override the default connection string it will be different depending on the database and whether it is in QA or Production. So I cannot have one giant context as it will not work in QA and Production. So I ask have there been any great strides forward so that I can have more than one context in a query?

    Thank you.


    Kevin Burton

    Thursday, July 12, 2012 10:07 PM

Answers

  • Hi Kevin;

    Sorry to say that functionality is still not supported in Entity Framework.

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Marked as answer by KevinBurton Friday, July 13, 2012 4:16 AM
    Friday, July 13, 2012 12:02 AM