MiniProfiler 2.1, LLBLGen Pro v3.5 Final, Self Servicing and typed views

Posts   
 
    
wolan
User
Posts: 5
Joined: 16-Apr-2013
# Posted on: 16-Apr-2013 21:58:52   

Hello,

I'm using MiniProfiler 2.1, LLBLGen Pro v3.5 Final Self Servicing and Sql Server 2012. When I try to call Fill method on typed view class, I get an exception:

Unable to cast object of type 'StackExchange.Profiling.Data.ProfiledDbConnection' to type 'System.Data.SqlClient.SqlConnection'.

Part of the stack trace:

[InvalidCastException: Unable to cast object of type 'StackExchange.Profiling.Data.ProfiledDbConnection' to type 'System.Data.SqlClient.SqlConnection'.] System.Data.SqlClient.SqlCommand.set_DbConnection(DbConnection value) +26 System.Data.Common.DbCommand.set_Connection(DbConnection value) +9 SD.LLBLGen.Pro.ORMSupportClasses.Query.set_Connection(DbConnection value) +26 SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.GetMultiAsDataTable(IEntityFields fieldsToReturn, DataTable tableToFill, IRetrievalQuery queryToUse, ITransaction transactionToUse) +62

I've configured MiniProfiler & LLBLGen like daelmo in thread http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=21599&HighLight=1.

Does anyone have any ideas how to fix it? I've seen thread http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=21673&HighLight=1, but overriding CreateDataAdapter method in CommonDaoBase partial class didn't help.

best regards, wolan

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 17-Apr-2013 01:40:16   

Which runtime library version are you using? Please refer to the forum guidelines.

wolan
User
Posts: 5
Joined: 16-Apr-2013
# Posted on: 17-Apr-2013 07:33:07   

3.5.12.601

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 17-Apr-2013 08:53:36   

I can't reproduce it. But I'm using MiniProfiler 2.0.2. Please update to the latest LLBLGen RTL, then test again. If that doesn't help please back to MiniProfiler 2.0.x and test again.

Also make sure you follow the instructions at http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=21599&StartAtMessage=0&#121662

(Edit) Tested with MiniProfiler 2.1 and it worked. So please double check the steps in the other thread.

David Elizondo | LLBLGen Support Team
wolan
User
Posts: 5
Joined: 16-Apr-2013
# Posted on: 17-Apr-2013 09:41:24   

Works for me now. I followed your instructions, but is started working after changing partial CommonDaoBase implementation to:


    public partial class CommonDaoBase
    {
        public override System.Data.Common.DbDataAdapter CreateDataAdapter()
        {
            var adapter = base.CreateDataAdapter();
            return new ProfiledDbDataAdapter(adapter, MiniProfiler.Current);
        }
    }

Thanks. Have a nice day.

wolan
User
Posts: 5
Joined: 16-Apr-2013
# Posted on: 05-May-2013 20:45:14   

Unfortunately, it doesn't work as expected. There are no exceptions, but profiler doesn't show queries from typed views. After overriding DetermineConnectionToUse method, I see exception like I have written in my first message in thread. Any thoughts?

daelmo, you have written, that I should update to the latest LLBLGen RTL. What does it mean? Are there any newer 3.5.* dlls? If so, where? Or should I update to LLBLGen 4?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 06-May-2013 07:01:09   

wolan wrote:

Unfortunately, it doesn't work as expected. There are no exceptions, but profiler doesn't show queries from typed views. After overriding DetermineConnectionToUse method, I see exception like I have written in my first message in thread. Any thoughts?

I can't reproduce it. I can see the sql in MiniProfiler when filling a TypedView. I'm attaching an image showing the sql and a repro case. Please take a look an see if you can reproduce it using that.

wolan wrote:

daelmo, you have written, that I should update to the latest LLBLGen RTL. What does it mean? Are there any newer 3.5.* dlls? If so, where? Or should I update to LLBLGen 4?

You can download the latest v3.5 runtime library version going into LLBLGen Site - Customer Area - Downloads. See this to know what RTL are you using right now.

David Elizondo | LLBLGen Support Team
wolan
User
Posts: 5
Joined: 16-Apr-2013
# Posted on: 07-May-2013 12:25:59   

daelmo wrote:

I can't reproduce it. I can see the sql in MiniProfiler when filling a TypedView. I'm attaching an image showing the sql and a repro case. Please take a look an see if you can reproduce it using that.

Thank you for your sample code. Now I see, why you can't see an exception I have written about. I have mapped stored procedure to typed view.

I have done that on your sample solution and I got an exception. I have mapped Employee Sales by Country sproc. Any thoughts?

I have used newest (?) LLBLGenPRO v3.5 runtime library: 3.5.13.429.

best regards, Marcin

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 08-May-2013 08:29:21   

I see the problem. The SP calls uses another pipeline to create the DBCommand that doesn't use the custom DynamicQueryEngineProfiled class. I see what I can do to show you the additional code you should use...

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 08-May-2013 11:50:06   

This is unfortunately not solvable. We create the commands and parameters using the dbproviderfactory and not through the connection, as that's unknown at that location: it creates a IRetrievalQuery object without a connection, which is later on assigned to the command. As the connection isn't available at that location, we can't create the command from the connection.

Either use our own profiler (for more deep analysis), or use glimpse (for lightweight profiling inside a webpage) which work both with dbproviderfactory injection so they'll work in all cases.

Frans Bouma | Lead developer LLBLGen Pro