Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using LINQ to SQL with multiple databases

2 views
Skip to first unread message

Stuart Ferguson

unread,
May 6, 2010, 6:17:16 PM5/6/10
to
I am working on a new project and hoping to use LINQ to SQL for the data
access but have come across the following issue.

I need to have my application access 3 databases with similar but not
the same table structure, for example

Database1 and Database 2 has a table called tblCustomer with 2 columns
CustomerKey and CustomerName

Database2 has a table called tblCustomer with 3 columns CustomerKey,
CustomerName and CustomerPostCode

I am looking for a solution that will allow me a query all three
databases without the need for 3 GetCustomerList functions as Database1
and Database2 could use the same function as are the same structure,
with an override function for database 3 to bring back the additional
field.

Is there a way i can declare a base datacontext class to handle Database
1 and 2 with an inherited version for Database 3.

Thanks In Advance

Stuart Ferguson

*** Sent via Developersdex http://www.developersdex.com ***

Mr. Arnold

unread,
May 6, 2010, 9:40:21 PM5/6/10
to

If you're talking about going to the designer and start changing code, I
wouldn't advise it.

You should just add the 3 databases with the tables needed to the
project using Linq_2-SQL and just query across databases
with one Linq query statement against 3 contexts.

If you don't want to do that, then use ADO.NET, SQL Command object, and
a sproc.

Your other option would be to use ADO.Entity Framework, possibly using
Entity-SQL.

0 new messages