开发者

Configure Mvc Mini Profiler with Linq DataCotext

开发者 https://www.devze.com 2023-04-01 03:22 出处:网络
I\'m using linq-to-sql datacontext for an application. I have the following class UserDataContext which I instantiate the table with

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();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号