Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to perform joins across different databases using LINQ?

Is it possible to perform joins across different databases using LINQ? If yes then how?

like image 705
santosh singh Avatar asked Nov 25 '10 16:11

santosh singh


People also ask

Can you join data from different databases?

SQL Server allows you to join tables from different databases as long as those databases are on the same server. The join syntax is the same; the only difference is that you must fully qualify table names.

Can we use joins in LINQ?

In LINQ, an inner join is used to serve a result which contains only those elements from the first data source that appears only one time in the second data source. And if an element of the first data source does not have matching elements, then it will not appear in the result data set.

How LINQ with databases can be used?

In LINQ to SQL, the data model of a relational database is mapped to an object model expressed in the programming language of the developer. When the application runs, LINQ to SQL translates into SQL the language-integrated queries in the object model and sends them to the database for execution.


1 Answers

If the databases are on the same server, you can create views (and 3 part naming) so that all the tables are queryable from one database.

If the databases are on different servers, you can use linked servers and views (and 4 part naming) so that all the tables are queryable from one database.

like image 119
Amy B Avatar answered Sep 30 '22 18:09

Amy B