Closed jchristenson closed 11 years ago
Well, a connection created with SqlFu is a SqlFuConnection , so I think you can try this
var realCnx=(db as SqlFuConnection).Connection;
//do the wrapping
That doesn't work, because the MiniProfiler needs to update the raw DbConnection with a ProfiledDbConnection so that it can monitor the queries. SqlFuConnection.Connection can't be updated
Then, the only way is to modify the source to set the internal connection inside SqlFuConnection.
I can do that, but I would prefer to use the source code as is. That is too bad, I really like what I see so far from SqlFu, but I also really want to have the MiniProfiler working so I can see the results.
I've modified SqlFuConnection (devel branch, but it will be included in the next release) to accept a DbConnection. So, perhaps this will work for you
var cnn=new SqlConnection(cnxString);
var profilerCnx=new StackExchange.Profiling.Data.ProfiledDbConnection(cnn, MiniProfiler.Current);
var db= new SqlConnection(profilerCnx,DbEngine.SqlServer);
Should the last statement in your example be var db = new SqlFuConnection(profilerCnx, DbEngine.SqlServer);
?
Indeed, you're right.
var cnn=new SqlConnection(cnxString);
var profilerCnx=new StackExchange.Profiling.Data.ProfiledDbConnection(cnn, MiniProfiler.Current);
var db= new SqlFuConnection(profilerCnx,DbEngine.SqlServer);
That will work perfect. When will the update make the normal download and nuGet package?
SqlFu 2.1.0 was released today
Is there any way to wrap the db connection used by SqlFu with a MiniProfiler profiled connection so the results of the queries can be profiled? The only thing I can think of is to write a new class that implements IHaveDbProvider that inherits from one of the current providers and wraps the connection.
Thanks, John