How does LinqPad generate a single SQL across databases?
Just wondering in this era of Entity Framework Core, how does LinqPad under the covers support querying across databases? I click on the SQL tab I see a unified SQL statement with fully qualified database.schema.table names and everything works. Is there any way to do this within my applications? Everything I find online indicates that short of creating views or other hacks, you can't query across databases with DbContext. But somehow, LinqPad manages. ?
Comments
It seems that nothing really special is going on, the additional types are declared in another class and the datacontext is passed by reference.
The trick is to specify the fully qualified name in the name attribute:
For EF, it won't work, even with 'hackish' schema. Exception:
Invalid object name 'Nutshell.dbo.Customer'.
There is a workaround described here: https://stackoverflow.com/a/26922902/1105812
Example code: