Overwriting the CatalogName

Posts   
 
    
HcD avatar
HcD
User
Posts: 214
Joined: 12-May-2005
# Posted on: 14-Sep-2015 14:47:55   

Hi,

(using LLBLGen 4.2 - but this is an "old" feature)

the catalalogname can be overwritten in 2 ways, either by Config :


<sqlServerCatalogNameOverwrites>
    <add key="OldCatalogName" value="NewCatalogName" />
</sqlServerCatalogNameOverwrites>

or by Code :


 CatalogNameOverwriteHashtable overwrite = new CatalogNameOverwriteHashtable { { "OldCatalogName", "newCatalogName"} };//pass this to the DataAccessAdapter constructor

There is a subtle difference though, by using the config, you can specify "*" as oldcatalogname, meaning that the catalogname will always be the new name, whatever the old name was.

The *-notation is not possible when overwriting via code. How can this be achieved ? How can I programmatically get to know the "OldCatalogName" so I can use in in the overwrite ?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 15-Sep-2015 04:30:44   

Single name setting (provided for backwards compatibility, not recommended). This option lets you specify a single new name for the catalog to use, or clear the catalog names altogether. It affects all catalog names known in the project, and therefore not very flexible. To use this option, use either the constructor of the DataAccessAdapter class which accepts CatalogNameToUse and CatalogNameUsageSetting or set these properties of the DataAccessAdapter class after instantiation of that class. CatalogNameToUse is important for the CatalogNameUsageSetting.ForceName as it will become the new name to use as catalog name. •Multi name setting Preferred way of performing catalog name overwriting. To do this, create a new CatalogNameOverwriteHashtable (type provided by the SD.LLBLGen.Pro.ORMSupportclasses assembly). You can specify a CatalogNameUsageSetting, but this isn't required. You then add key-value pairs, where the key is the name to overwrite and the value is the name to overwrite it with. If you specify '*' as key, all catalog names will be set to the name specified as value, if CatalogNameUsageSetting is set to ForceName. Please see the LLBLGen Pro reference manual for more details on this object. The created CatalogNameOverwriteHashtable is then passable to the DataAccessAdapter constructor or you can set the CatalogNameOverwrites properties to an instance of this special hashtable.

You can either use the Single Name setting, or you need to set the DataAccessAdapter's CatalogNameUsage to ForceName (Or set it to Clear, and use the catalogName specified in the connection string, which also can be passed in code to the Adapter's CTor).

HcD avatar
HcD
User
Posts: 214
Joined: 12-May-2005
# Posted on: 15-Sep-2015 15:31:23   

Thanks ! I must have overlooked that in the docs, indeed I changed my line of code to :

     CatalogNameOverwriteHashtable overwrite = new CatalogNameOverwriteHashtable(CatalogNameUsage.ForceName) { { "*", NewCatalogName } };

and it works !