Catalog Name Overwriting with NO config file

Posts   
 
    
dazedorconfused avatar
Posts: 89
Joined: 06-Apr-2006
# Posted on: 07-Feb-2013 19:47:59   

**LLBLGen Pro version + buildnr: **Version 3.5 Final - Released September 17th, 2012

**Runtime library version: **3.5.12.1004

**Template group + .NET version: **Self-Servicing, .Net 4.0

**Database type and version: **SQL Server 2008 R2

I have a class library that I have written that uses LLBLGenPro and is now being used in a non - .Net application. So, I need a way to overwrite the SQL Server Catalog name that does NOT involve using a config file. I cannot find info on how to do this completely with code.

Just to reiterate... I am looking for an all code alternative to this...


  <configSections>
    <section name="sqlServerCatalogNameOverwrites" "System.Configuration.NameValueSectionHandler"/>
  </configSections>
  <sqlServerCatalogNameOverwrites>
    <add key="EOLTest" value=""/>
  </sqlServerCatalogNameOverwrites>


Any help would be greatly appreciated!!

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Feb-2013 20:28:43   

Not an easy task in SelfService, please check the following thread: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=15875

I'd recommend switching to Adapter, if you can.

dazedorconfused avatar
Posts: 89
Joined: 06-Apr-2006
# Posted on: 07-Feb-2013 20:39:03   

I'm dealing with an application that is completely written. Isn't switch from SelfServicing to Adapter a pretty big undertaking?

dazedorconfused avatar
Posts: 89
Joined: 06-Apr-2006
# Posted on: 07-Feb-2013 20:51:11   

I am open to using a config file versus rewriting the application. How would I go about using a config file the application instantiating the dll is not .Net based. I have looked into loading a config file using something like

Configuration config = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);

but I wouldn't know where to implement that to let the ORM Support classes know where the config file is.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 08-Feb-2013 06:51:31   

dazedorconfused wrote:

I'm dealing with an application that is completely written. Isn't switch from SelfServicing to Adapter a pretty big undertaking?

It depends how large is your code and how you decoupled it's. However, if Adapter is most suitable for your type of application, maybe it would be a good switch.

You could use CatalogNameOverwrites setting the newValue to empty (""). That way the catalog you use in the connectionString is used, even when you set it at runtime. Example:

<configSections>
   <section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueSectionHandler" />
</configSections>

<appSettings>
   <add key="NW.ConnectionString.SQL Server (SqlClient)" value="data source=.;initial catalog=Northwind;integrated security=SSPI;persist security info=False;packet size=4096"/>
</appSettings>

<sqlServerCatalogNameOverwrites>
   <add key="Northwind" value="" />
</sqlServerCatalogNameOverwrites>
CommonDaoBase.ActualConnectionString = @"data source=.;initial catalog=NW3;integrated security=SSPI;persist security info=False;packet size=4096";
            
var customers = new CustomerCollection();
customers.GetMulti(null);
David Elizondo | LLBLGen Support Team
dazedorconfused avatar
Posts: 89
Joined: 06-Apr-2006
# Posted on: 08-Feb-2013 16:44:11   

David, My biggest issue is that I needed to figure out a way to make CatalogNameOverwrites work without a config file. I now see that that is simply not an option with self servicing. Given my current time table, rewriting target the Adapter framework is not an option.

So... I will use a config file. My new issue is, how do I let the ORM know what config file to use when the application referencing my class library is not a .Net application. To be specific, it is an application written using National Instrument's LabView platform.

Please see attached pdf.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 09-Feb-2013 05:59:26   

I don't know how you can tell .net what .config to use. I saw some voodoo methods out there to load other partial configs, but not a total .config.

A config is another file you can load on your app. So if you can load it and determine the connection string to use, you can use it to set the CommonDaoBase.ActualConnectionString at runtime. I don't know if you can load a totally different .config just to LLBLGen purposes, but you should test that of course.

David Elizondo | LLBLGen Support Team