views:

14

answers:

1

My program (WCF service programed in C#) has to access multiple sql server groups and the databases within those groups (sql server). It looks like linq 2 sql definitely doesn't support this unless I create multiple dataclasses per database, and it looks like the entity framework is in the same boat.

How would you go about setting up your application that has to access multiple sql server groups that are not linked?

I suppose I could just use SqlConnection and SqlCommand and create some classes to handle it. If I go this route how would I go about populating my model classes with the result of the query? (I don't want to use datatables, but rather List<T>)

I.E.

Server1
 - database 1
 - database 2
Server2
 - database 3
 - database 4

My program has to access database 1 and database 4, and they're not linked / will not be linked.

A: 

You can use EF or LinqToSql to access each DB. Your service will work like broker. It will collect results from different databases and constructs DTOs with complete data.

Edit:

If you have SPs with same name you can reuse single EF model. If you have SPs with different names you can create model for each database. The entities will be actually same so you can use POCO approach (only EF 4.0) which maps entity from model to your POCO class. POCO class will be used by all models.

Ladislav Mrnka
@Ladislav - this is true but from my understanding I would have to create a new linq 2 sql or EF file for each database... which I'm trying to avoid doing. I want them to share the same DTO's.
Chris Klepeis
These databases have same structure? So you want to pull same data from those databases?
Ladislav Mrnka
No, the database structures are completely different, but the SP's I want to call alias the fields to fit the model object. I.E. querying for an address in one db looks at different tables than querying for an address in another db, however, the SP will return the same field names to populate the same object model.
Chris Klepeis
So I guess you are looking for EF 4.0 + POCO where POCO will be shared. Check modified answer.
Ladislav Mrnka