Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > ORM Profiler Section > Bugs & Issues> How to use with PetaPoco
 

Pages: 1
Bugs & Issues
How to use with PetaPoco
Page:1/1 

  Print all messages in this thread  
Poster Message
jovball
User



Location:

Joined on:
25-Jul-2014 04:27:34
Posted:
9 posts
# Posted on: 22-Jul-2016 02:35:59.  
I'm doing some micro ORM testing and demos for our developer team. I've got ORM Profiler working with Dapper thanks to the Help documentation. I'd like to also get it working with PetaPoco (haven't gotten to Massive yet). I'm not capturing anything yet from PetaPoco. Any suggestions for what I need to do there?
  Top
Otis
ORM Profiler Team



Location:
The Hague, The Netherlands
Joined on:
22-Aug-2011 10:26:38
Posted:
613 posts
# Posted on: 23-Jul-2016 10:21:27.  
It should be work out of the box, as it simply defaults to SqlClient factory. Check Database constructor in PetaPoco.cs to see what factory it obtains in the debugger. And make sure you call the interceptor before anything else of course Regular Smiley

Frans Bouma
ORM Profiler / LLBLGen Pro Lead Developer | Blog | Twitter
 
Top
jovball
User



Location:

Joined on:
25-Jul-2014 04:27:34
Posted:
9 posts
# Posted on: 23-Jul-2016 15:03:30.  
I thought that it would but it isn't working for me so far. Here are a few code fragments. It's just a simple console app. I'm calling the ORMProfile Initialize at the start of the Main method.

Code:


static void Main(string[] args)
        {
            SD.Tools.OrmProfiler.Interceptor.InterceptorCore.Initialize("ORM Demo Console App");
            var qr = new QueryRepository();
            var orders = qr.FetchOrders();
            var orderCount = orders.Count;
            logger.Debug($"Fetched {orders.Count} order header items from the Northwind database");

            Console.ReadLine();
        }



In PetaPoco, I see this when I step through the debugger. All of this looks right to me but ORM Profiler is capturing anything. Here are some snippets from the Database, Initialize and OpenSharedConnection methods along with the values I see for Provider, Factory, etc.

line 140
Database method. this calls Initialize with value of System.Data.SqlClient
Code:

var providerName = !string.IsNullOrEmpty(entry.ProviderName) ? entry.ProviderName : "System.Data.SqlClient";
            Initialise(DatabaseProvider.Resolve(providerName, false, _connectionString), null);





line 231
Initialize method
Code:

_provider = provider; //PetaPoco.SqlServerDatabaseProvider
_factory = _provider.GetFactory(); //System.Data.SqlClient.SqlClientFactory


line 261
OpenSharedConnection() //Opening the connection at query time
Code:

_sharedConnection = _factory.CreateConnection(); // System.Data.SqlClient.SqlConnection
_sharedConnection.ConnectionString = _connectionString;


Perhaps you'll notice something obvious from this.
  Top
Otis
ORM Profiler Team



Location:
The Hague, The Netherlands
Joined on:
22-Aug-2011 10:26:38
Posted:
613 posts
# Posted on: 24-Jul-2016 09:51:19.  
My code is on other lines. I look at 4.0.3, which version are you using?

Anyway, Database() has an overload which accepts a dbconnection, you could use the linq to sql workaround there. However there's a problem later on in CommonConstruct: You have to adjust it a bit to make sure it selects the right db type.



Frans Bouma
ORM Profiler / LLBLGen Pro Lead Developer | Blog | Twitter
 
Top
jovball
User



Location:

Joined on:
25-Jul-2014 04:27:34
Posted:
9 posts
# Posted on: 26-Jul-2016 14:14:39.  
I'm using PetaPoco 5.1.206.
  Top
Otis
ORM Profiler Team



Location:
The Hague, The Netherlands
Joined on:
22-Aug-2011 10:26:38
Posted:
613 posts
# Posted on: 27-Jul-2016 09:47:01.  
jovball wrote:
I'm using PetaPoco 5.1.206.

Then I don't know. it's not officially supported, so if there's no way to pass in a connection object or that it uses dbprovider factory then I guess it's not going to work. I have no idea why it doesn't use the dbproviderfactory, but perhaps they refactored it to be able to run on .net core which uses dbproviderfactory but not the central table so it's likely hard-coded.

Did you ask PetaPoco what could be the problem?


Frans Bouma
ORM Profiler / LLBLGen Pro Lead Developer | Blog | Twitter
 
Top
jovball
User



Location:

Joined on:
25-Jul-2014 04:27:34
Posted:
9 posts
# Posted on: 27-Jul-2016 13:19:35.  
I haven't asked there yet. I'll do that next.
  Top
Otis
ORM Profiler Team



Location:
The Hague, The Netherlands
Joined on:
22-Aug-2011 10:26:38
Posted:
613 posts
# Posted on: 28-Jul-2016 10:08:29.  
jovball wrote:
I haven't asked there yet. I'll do that next.

I guess this is the problem:
https://github.com/CollaboratingPlatypus/PetaPoco/blob/development/PetaPoco/Providers/SqlServerDatabaseProvider.cs#L20

They hard-coded get the sqlserver factory, not through the official .net framework channels. I guess this is done for .NET core, so changing that to a regular DbProviderFactories.GetFactory(name) call will make your code not work on .NET core (yet)


Frans Bouma
ORM Profiler / LLBLGen Pro Lead Developer | Blog | Twitter
 
Top
jovball
User



Location:

Joined on:
25-Jul-2014 04:27:34
Posted:
9 posts
# Posted on: 03-Aug-2016 13:00:21.  
FYI. I have an open issue with PetaPoco on GitHub. You can track it if you like. https://github.com/CollaboratingPlatypus/PetaPoco/issues/314 . It looks like I can use one of the Database constructor overloads to do the same type of thing as Dapper. However, the code is written to throw an exception if it doesn't recognize the type (ProfilerDbConnection ).
  Top
Otis
ORM Profiler Team



Location:
The Hague, The Netherlands
Joined on:
22-Aug-2011 10:26:38
Posted:
613 posts
# Posted on: 04-Aug-2016 08:43:54.  
Hmm, then I guess you have to alter the petapoco code a bit and compile from source instead of using the nuget package.

(edit) I've commented on the github issue with an example how they can fix it, as it's an easy method to solve. We use it too (I referred to the comment with the code we use)


Frans Bouma
ORM Profiler / LLBLGen Pro Lead Developer | Blog | Twitter
 
Top
jovball
User



Location:

Joined on:
25-Jul-2014 04:27:34
Posted:
9 posts
# Posted on: 05-Aug-2016 00:32:10.  
Yes, I saw your comment on github. Thanks for the help so far. I'll see where the developer wants to go next. I can alter the code but it's never my first choice because of the problems it can cause with new versions.
  Top
jovball
User



Location:

Joined on:
25-Jul-2014 04:27:34
Posted:
9 posts
# Posted on: 05-Aug-2016 04:32:18.  
Nicely done, PetaPoco will add the changes you recommended to work with ORM Profiler.

LLBLGen is still where I am doing my real work but I like to kick the tires and see what else is out there. Everytime I do comparisons, I realize what a great tool LLBLGen is. It's helpful to have ORM Profiler to capture the statements, especially since I work with one database that does not make it easy to profile/trace at the database level.

Thanks again.


  Top
Otis
ORM Profiler Team



Location:
The Hague, The Netherlands
Joined on:
22-Aug-2011 10:26:38
Posted:
613 posts
# Posted on: 05-Aug-2016 09:43:10.  
jovball wrote:
Nicely done, PetaPoco will add the changes you recommended to work with ORM Profiler.

Regular Smiley

Quote:

LLBLGen is still where I am doing my real work but I like to kick the tires and see what else is out there. Everytime I do comparisons, I realize what a great tool LLBLGen is. It's helpful to have ORM Profiler to capture the statements, especially since I work with one database that does not make it easy to profile/trace at the database level.

Thanks again.

Thanks for the kind words Joel Regular Smiley Hopefully things are fixed a.s.a.p. in PetaPoco! Regular Smiley
Frans Bouma
ORM Profiler / LLBLGen Pro Lead Developer | Blog | Twitter
 
Top
jovball
User



Location:

Joined on:
25-Jul-2014 04:27:34
Posted:
9 posts
# Posted on: 08-Aug-2016 05:55:32.  
Frans, I think that Wade and I are going in circles on this. He is expecting me to pass the ORM Profiler provider and I'm pretty sure that's not what you were expecting.

  Top
Otis
ORM Profiler Team



Location:
The Hague, The Netherlands
Joined on:
22-Aug-2011 10:26:38
Posted:
613 posts
# Posted on: 08-Aug-2016 10:21:12.  
jovball wrote:
Frans, I think that Wade and I are going in circles on this. He is expecting me to pass the ORM Profiler provider and I'm pretty sure that's not what you were expecting.

Yeah. I've replied, hopefully that gets him on the right track Regular Smiley
Frans Bouma
ORM Profiler / LLBLGen Pro Lead Developer | Blog | Twitter
 
Top
Pages: 1  


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

Version: 2.1.09082011 Final.