开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜