Configure Mvc Mini Profiler with Linq DataCotext
I'm using linq-to-sql datacontext for an application. I have the following class
UserDataContext which I instantiate the table with
var db = new UserDataContext();
How do I make Mvc Mini Profiler insert into that?
I tried to extend UserDataContext with the following partial found at another answer, but the code is never hit.
partial class UserDataContext
{
public static UserDataContext Get()
{
var sqlConnection = new HelpSaudeAPDataContext().Connection;
var profiledConnection = new MvcMiniProfiler.Data.ProfiledDbConnection(new SqlConnection("UserConnectionString"), MiniProfiler.Current);
开发者_如何学Creturn new HelpSaudeAPDataContext(profiledConnection);
}
}
Unfortunately there is no single point repository with the var db connection where I could simply pass the mvc mini profiler connection with.
var db = UserDataContext(profilerConnection);
but the code is never hit.
Well, hit it:
var db = UserDataContext.Get();
精彩评论