Domanda

When writing sql, I can do

 BEGIN Trans t;
 SELECT a.name, b.name from db1.dbo.A as a
    JOIN db2.dbo.B as b
    ON b.aId = a.Id
 COMMIT Trans t;

When two databases are on the same database instance.

I am wondering how I can achieve this with database mapping. So that I don't need to create multiple sessions for queries involves different databases.

È stato utile?

Soluzione

No, so far I have not seen any other solution then creating a view within one database which does the cross DB query and then use nh mappings on that view, or maybe fully-qualified names. (see duplicate-link below your post).

Altri suggerimenti

There is a possibility to do it with DB synonyms. It is not an optimal solution performance-wise, but it might solve your current bind. SQL Server Synonyms

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top