Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> Catalogname in Retrieval SP is not overwritten.
 

Pages: 1
LLBLGen Pro Runtime Framework
Catalogname in Retrieval SP is not overwritten.
Page:1/1 

  Print all messages in this thread  
Poster Message
jwijnker
User



Location:
Amsterdam
Joined on:
09-Mar-2011 10:44:18
Posted:
32 posts
# Posted on: 02-Nov-2012 17:51:06.  
Using LLBLGen Pro Version 3.1 Final (March 12th, 2012)
Using Template: Adapter
Target Platform: .NET 2.0
SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll File version 3.1.12.0806

I try to execute a SP :

Code:

public static InvoicesTypedView SP_GetInvoices(int amount)
{
    InvoicesTypedView result = new InvoicesTypedView ();

    var query = RetrievalProcedures.GetQueryFor InvoicesTypedView (amount    );

    using (var daa = DataSourceHelper.GetDataAccessAdapter())
    {
        daa.FetchTypedView(result, query);
    }
    return result;    
}


When I monitor (IRetrievalQuery) ‘query’ the referenced catalog is ‘tenant’.

In the dataAccessAdapter I use catelog overwrites.
Code:


    public partial class DataAccessAdapter : Data.DatabaseSpecific.DataAccessAdapter
    {
        private const string TENANT_CATALOG_NAME_TO_USE_SETTING_KEY = "DefaultCatalogNameToUse";
        private const string MASTER_CATALOG_NAME_TO_USE_SETTING_KEY = "MasterCatalogNameToUse";

        private const string TENANT_DATABASE_CATALOG_NAME = "Tenant";
        private const string MASTER_DATABASE_CATALOG_NAME = "Master";

        public DataAccessAdapter() : base() {

            this.CatalogNameUsageSetting = CatalogNameUsage.Default;

            this.CatalogNameOverwrites = new CatalogNameOverwriteHashtable(CatalogNameUsage.Default);
            this.CatalogNameOverwrites.Add(TENANT_DATABASE_CATALOG_NAME, System.Configuration.ConfigurationManager.AppSettings[TENANT_CATALOG_NAME_TO_USE_SETTING_KEY]);
            this.CatalogNameOverwrites.Add(MASTER_DATABASE_CATALOG_NAME, System.Configuration.ConfigurationManager.AppSettings[MASTER_CATALOG_NAME_TO_USE_SETTING_KEY]);
        }

}


I've read the thread http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=20590 and expected that the catalogoverwrites should also work on sp's.

Why is the catalogname not rewritten for StoredProcedures? I use the same DataAccessAdapter for fetching other entities, where the catalogname gets rewritten.
  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8095 posts
# Posted on: 03-Nov-2012 05:50:00.  
The thing is: when you call
Code:
var query = RetrievalProcedures.GetQueryFor InvoicesTypedView (amount );

... the query must be constructed with some schema/catalog, so the frameworks instantiate a normal DataAccessAdapter to do that. Then wjen you use your custom daa, it's too late to insert that overrides. This thread reveals a similar situation: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=21272&HighLight=1

My recommendation is to do this:
Code:
public static InvoicesTypedView SP_GetInvoices(int amount)
{
    InvoicesTypedView result = new InvoicesTypedView ();
    using (var daa = DataSourceHelper.GetDataAccessAdapter())
    {
         RetrievalProcedures.FetchInvoicesTypedView(daa, result, amount);
    }
    return result ;    
}

... so it always use your custom adapter.


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
jwijnker
User



Location:
Amsterdam
Joined on:
09-Mar-2011 10:44:18
Posted:
32 posts
# Posted on: 04-Nov-2012 00:15:44.  
Thanks for your reply!
Unfortunatly I can't find any method in RetrievalProcedures with such a signature...

Even when I use this code where the query is created when the daa is already loaded, then correct catalog isn't set.
Code:

public static InvoicesTypedView SP_GetInvoices(int amount)
{
    InvoicesTypedView result = new InvoicesTypedView();

    using (var daa = DataSourceHelper.GetDataAccessAdapter())
    {
        
        var query = RetrievalProcedures.GetQueryFor InvoicesTypedView (amount    );

        daa.FetchTypedView(result, query);
    }
    return result;    
}


I have 3 options in the RetrievalProcedures for this SP. 1 returns a DataTable, the other 2 return a IRetrievalQuery. All 3 options do fail in the catalog-overwrite.

Do I miss a 'using'-statement? or does it matter I do not give the catalogRewriteTable as a constructor-argument?
  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8095 posts
# Posted on: 04-Nov-2012 21:12:10.  
Even if you place the call inside the using statement it wont work because you are not passing the the adapter object. There should be a RetrievalProcedures call that receives an adaper parameter for that TypedView.

David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
jwijnker
User



Location:
Amsterdam
Joined on:
09-Mar-2011 10:44:18
Posted:
32 posts
# Posted on: 05-Nov-2012 09:55:10.  
The only option left where i can pass a DataAccessAdapter is:

Code:

using (var daa = DataSourceHelper.GetDataAccessAdapter())
{
    InvoicesTypedView result = new InvoicesTypedView();

    var dataTable = RetrievalProcedures.GetInvoices(
        Amount,
        daa
    );

    
    result.Load(dataTable.CreateDataReader());
}


Now I can execute the SP (using a dataTable) and get the TypedView as a result.
Thanks.
  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.