Connection String partially ignored by generated code

Posts   
 
    
thisbox71
User
Posts: 4
Joined: 12-Oct-2006
# Posted on: 06-Jun-2008 19:38:45   

My LLBL info LLBLGen Pro 2.5 Final SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll runtime version 2.5.07.1019 Adapter + .NET 2.0 MSSQL 2000/2005

I have created 2 databases on the same MSSQL server. One is called 'Dev' and the other is called 'Current'

Here's the code:

        [TestMethod]
        public void TestMethod1()
        {
            string connstr;

            // DevDB
            connstr = ConfigurationManager.ConnectionStrings["DevDB.ConnectionString"].ConnectionString;
            RunTests(connstr);

            // CurrentDB
            connstr = ConfigurationManager.ConnectionStrings["CurrentDB.ConnectionString"].ConnectionString;
            RunTests(connstr);
        }

        private void RunTests(string connstr)
        {
            try
            {
                TrxEntity objTrxEntity = new TrxEntity();
                objTrxEntity.TransactionID = "TEST00";
                objTrxEntity.TxnDateTime = DateTime.Now;
                objTrxEntity.TxnSentBy = "USER01";
                objTrxEntity.TxnSentTo = "USER02";
                objTrxEntity.TxnTypeCode = "NR";
                objTrxEntity.TNResNo = 1001;
                objTrxEntity.BookerMemberCode = "Booker One";
                objTrxEntity.BookerResNo = "BOOKER01";
                objTrxEntity.ProviderMemberCode = "Provider One";
                objTrxEntity.ProviderResNo = "PROVIDER01";

                DataAccessAdapter d = new DataAccessAdapter(connstr);
                d.SaveEntity(objTrxEntity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

When this runs, the test passes, but it writes 2 entries to the Dev.dbo.Tb_Trx table instead of one entry to each table in the different databases.

If I remove the test for the Dev db and take the Dev db offline, the code fails even though the Current db is online.

Here's the stack trace for that exception at SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute() at SD.LLBLGen.Pro.ORMSupportClasses.BatchActionQuery.Execute() at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteActionQuery(IActionQuery queryToExecute) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.PersistQueue(List`1 queueToPersist, Boolean insertActions, Int32& totalAmountSaved) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave, IPredicateExpression updateRestriction, Boolean recurse) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.SaveEntity(IEntity2 entityToSave) at ULS.Test.LLBLTester.RunTests(String connstr) in D:\Projects\ULS\Current\ULS.Test\LLBLTester.cs:line 96

When I look at the entitly list in the code generator it shows that the table mapped on Dev.dbo.Tb_Trx, instead of just dbo.Tb_Trx

How do I make LLBL get this information from the connection string?

Thanks,

Rob Hill thisbox71 AT gmail.com

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 07-Jun-2008 01:45:51   

Hi Rob,

Passing the connection string doesn't make that the catalogName at connstr would be used for default. If you want that the catalog name grabbed in the connectionstring will be the one used by the adapter, please try this:

CatalogNameOverwriteHashtable overwriteCatalog = new CatalogNameOverwriteHashtable( CatalogNameUsage.Clear);
DataAccessAdapter adapter = new DataAccessAdapter(connstr, false, overwriteCatalog, null);

If you still have troubles, please attach your config file to look at the ConnectionStrings section and see what's wrong (you can post at HelpDesk forum if you need confidentiality).

David Elizondo | LLBLGen Support Team