开发者

It's possible to perform joins across different databases using LINQ?

开发者 https://www.devze.com 2023-01-26 17:05 出处:网络
It\'s possible to perform joins across different databases using LIN开发者_开发百科Q? If yes then how?Yes and no. A single linq query against L2S or L2E will be sent as one query down to the database.

It's possible to perform joins across different databases using LIN开发者_开发百科Q? If yes then how?


Yes and no. A single linq query against L2S or L2E will be sent as one query down to the database. That said, ff you are joining tables that exist in separate databases you can:

a) Run separate L2S/L2E queries against the two databases, and join the results client-side in a linq-to-objects query.
...or...

b) Use linked tables or views in the database to access tables in another database.
...or...

c) If the tables are in separate databases on the same machine and you're using Linq-to-SQL, and the login credentials you are using are allowed to access both databases, you can add the database name as a prefix in the dbml file. The generated queries will then target the right db.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号