Question about using multiple databases

Posts   
 
    
BertJ
User
Posts: 8
Joined: 12-Dec-2008
# Posted on: 13-Jan-2009 00:55:41   

Hi,

I have a question, I hope somebody can help me?

I used LLBLGen to generate a BusinessLayer where there is a class which has a property which is in facted mapped to a table in another database. So, my LLBLGen project has 2 catalogs, and there is one entity with a FK to a table in another database.

My question?

The connectionstrings of these 2 databases can change, depending on the context of the application, how do I set the connectionstring of the second database when fetching records / when committing changes?

We fetch our records like this:

using (var adapter = new DataAccessAdapter(Database.MDM_Master_Local_ConnectionString)) { var metaData = new LinqMetaData(adapter);

            var q = (from c in metaData.AssessmentFiles
                     where c.Id == aAssessmentFileId
                     select c)
                    .WithPath(assessmentFile => assessmentFile
                        .Prefetch<TextLabelsEntity>(c => c.SignAsTextLabel)
                        .Prefetch<AssessmentFileProgressEntity>(c => c.AssessmentFileProgress)
                        .Prefetch<AssessmentFilePicturesEntity>(c => c.AssessmentFilePictures)
                            .SubPath(assessmentfilepicture => assessmentfilepicture

** .Prefetch<PictureEntity>(c => c.Picture) **

The entity in bold is the entity which comes from another db, but how do I set the connectionstring if it should differ from the default (the one to where te catalog is linked)

The same question when committing changes to the db, we commit our changes using the UnitOfWork but we can set the connectionstring for the first database, but how for the second?

Thanks!

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 13-Jan-2009 04:48:47   

What exaclty could change on both connectionStrings (server, schema or catalog)?

David Elizondo | LLBLGen Support Team
BertJ
User
Posts: 8
Joined: 12-Dec-2008
# Posted on: 13-Jan-2009 12:11:49   

It is the server that changes, we have two machines and our application needs to talk to both of the machines.

On each machine we have two databases (with a relation in LLBLGen), the schema of the two databases are the same on both machines.

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 13-Jan-2009 12:17:51   

Then LLBLGen Uses the specified ConnectionString to access both catalogs. you only need one valid ConnectionString to access one catalog and then using Fully Qualified Names, you can access the other catalog.

So the bottom line: If the catalog names are the same on both servers. Then you don't have to worry about anything.