This is a migrated thread and some comments may be shown as answers.

Single linq query for two separate databases?

2 Answers 48 Views
Databases and Data Types
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Richard M
Top achievements
Rank 1
Richard M asked on 04 Dec 2010, 01:41 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Damyan Bogoev
Telerik team
answered on 08 Dec 2010, 06:48 PM
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.
0
Richard M
Top achievements
Rank 1
answered on 13 Dec 2010, 05:36 PM
Thank you, I will try that.
Tags
Databases and Data Types
Asked by
Richard M
Top achievements
Rank 1
Answers by
Damyan Bogoev
Telerik team
Richard M
Top achievements
Rank 1
Share this question
or