Using LINQ to SQL with multiple databases

Posted by Stuart Ferguson on Stack Overflow See other posts from Stack Overflow or by Stuart Ferguson
Published on 2010-05-07T09:10:19Z Indexed on 2010/05/10 7:04 UTC
Read the original article Hit count: 487

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about linq-to-sql

Related posts about inheritance