Single linq query for two separate databases?

3 posts, 1 answers
  1. Richard M
    Richard M avatar
    76 posts
    Member since:
    Mar 2010

    Posted 03 Dec 2010 Link to this post

    I have 2 separate EntityDiagrams in my program, one for Database1 and one for Database2.  Is it possible to create a single LINQ query that uses both EntityDiagrams within a single query?
  2. Answer
    Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 08 Dec 2010 Link to this post

    Hello Richard M,

    I am afraid that you are unable to execute a Linq query against more than one database simultaneously. Such support is not planned for the future yet.
    Actually you could execute the query in parts on the server and finish it on the client later using Linq to Objects. For instance try to provide filters for both queries and execute them applying the ToList() method. Then combine the result collections in one query which will be executed on the client:

    ...
    List<Class1> list1 = context1.Where(x => ...).ToList();
    List<Class2> list2 = context2.Where(x => ...).ToList();
    ...

    Hope that helps. If any other questions arise do not hesitate to contact us back.

    All the best,
    Damyan Bogoev
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
  3. DevCraft banner
  4. Richard M
    Richard M avatar
    76 posts
    Member since:
    Mar 2010

    Posted 13 Dec 2010 Link to this post

    Thank you, I will try that.
Back to Top