Dynamically switching database

Posts   
 
    
patmeth
User
Posts: 2
Joined: 11-Jun-2010
# Posted on: 11-Jun-2010 19:43:50   

Hello,

LLBLGen Version: 2.6 Template Group: Adapter .NET Version: 3.5 Database: SQL Server 2005 Code: bool hasSucceeded = adapter.CallRetrievalStoredProcedure("[ILAP_Dev_2.1_test].[dbo].[GetAdvertisementSpending]", parameters, toReturn); base.AddElementMapping( "AdminUserActionEntity", "ILAP_Dev_2.1_test", @"dbo", "AdminUserAction", 6 );

I generated the two database specific and general projects using llblgen. However the database name is embedded in the class files (eg. in PersistenceInfoProvider and Retrieval). How do I override the database name and make the projects dynamically get the database name from the configuration file where the project is being used?

I'm using Visual Studio 2008 and the two projects have been generated against a SQL Server 2005 database. The application using this code is an enterprise grade tiered architecture.

Thanks, Glenn

patmeth
User
Posts: 2
Joined: 11-Jun-2010
# Posted on: 11-Jun-2010 22:22:11   

I just wanted to add that in my case the connection string is not automatically picked up from the .config file. But, if I replace the database names in the generated class with a blank string, the connection string is picked up from the file.

For eg. if I convert this, base.AddElementMapping( "AdminUserEntity", "ILAP_Dev_2.1", @"dbo", "AdminUser", 14 );

to this, base.AddElementMapping( "AdminUserEntity", "", @"dbo", "AdminUser", 14 );

, the connection string is picked up from the app.config file.

Thanks, Glenn

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 12-Jun-2010 02:30:51   

Hi Glenn,

What you need is Schema name overwriting. You can leave blank the new schema to use and the one specified in the connection string is used.

David Elizondo | LLBLGen Support Team