Regarding PersistenceInfoProvider class(Adapter Model)

Posts   
 
    
prabhu
User
Posts: 77
Joined: 20-Dec-2006
# Posted on: 23-Apr-2007 11:38:38   

Hi,

We are using LLBLGenPro v2.0 for data layer generation in our project. We are using the adapter model to generate the code from db schema. I am having doubt in the Init() method of PersistenceInfoProvider.cs file.

  1. Generated the DAL layer based on db schema using a development sqlserver m/c.
  2. At later point of time we had moved the development sqlserver to another machine with existing schema but with different catalog(database name).
  3. We had changed only the appropriate connection string info in app.config file without regenerating the DAL Layer.
  4. While try to use the dal code (With new connection string) from our Business logic code it still points to the old catalog name and error shows up. While try to debug I had checked in the PersistenceInfoProvider.cs class. In the InitEntityNameEntityMappings method we found catalog name as hardcoded.

base.AddElementMapping( "EntityName", "OptimaTigerDatabase", @"Activity", "Action", 9 );

Actually we had changed the catalog name in the app.config from OptimaTigerDatabase to OptimaSG. Whether catalog name will be hardcoded while generating the code from Schema or any other way that will be configurable.

Help is very much appreciated.

Regards

Prabhu

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 23-Apr-2007 15:07:30   

Hello,

if you don't want to use the same database name, you can specify this in the config file:

In <appSettings> section :

<add key="Main.connectionString" value="Server=(local);Database=xxx;uid=xxx;pwd=xxx;"/> <add key="CatalogNameUsageSetting" value="1"/> <add key="CatalogNameToUse" value="MyCurrentDB" />

It will overrides the settings that are defined by default in the source code.

prabhu
User
Posts: 77
Joined: 20-Dec-2006
# Posted on: 24-Apr-2007 06:42:08   

Hi,

Thanks for the reply... The solution you had provided was to change the catalog name if the DAL generated was a different one. Tightly coupled to a single db

In our case we are developing a web based application that will be used across asia pacific region. We are using different database for each countries(around 20 countries).. The schema will be replicated(same) across each and every database.

While the user login by using their credentials and selecting the country i need to dynamically change the catalog name based on the user type.for example OptimaSG for singapore, OptimaIN for India, OptimaCN for china etc.

Regards

Prabhu

prabhu
User
Posts: 77
Joined: 20-Dec-2006
# Posted on: 24-Apr-2007 06:54:25   

Hi,

Shall i override the DataAccessAdapter class constructor

public DataAccessAdapter(string connectionString, bool keepConnectionOpen, CatalogNameUsage catalogNameUsageSetting, string catalogNameToUse)

for the above scenariro.

Help is very much appreciated.

Regards

Prabhu

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 24-Apr-2007 10:58:44   

You can call that constructor directly which is left for backward compatability, or you can override it in a derived class.