Reputation:
I have a database called MasterDatabase that has table MainIndex with columns Id, Database (nvarchar), Table(nvarchar)
and I have 2 other databases with tables and data.
Is there a way to substitute the FROM statement with results from the MasterDatabase.MainIndex?
Can this be done with LINQ?
Upvotes: 0
Views: 243
Reputation:
Another alternative is to add the table you want to select from from the second database as a view in the master database. You will then be able to map the view as an entity.
:)
Upvotes: 1
Reputation: 7491
Or you can access tables from another database by prefixing the tables in your .dbml with either [DatabaseName].[SchemaName].[TableName]
or if it's on a differenct server include the [ServerName]
as well... Then you wouldn't have to use Dynamic linq
Upvotes: 0
Reputation: 180787
You need the Linq Dynamic Query library to accomplish this. It allows you to do string substitutions in your Linq queries.
More info at http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx
Upvotes: 0