我正在为应用程序使用 linq-to-sql 数据上下文。我有以下课程
我用它实例化表的 UserDataContext
var db = new UserDataContext();
如何让 Mvc Mini Profiler 插入其中?
我尝试使用在另一个答案中找到的以下部分来扩展 UserDataContext ,但代码从未被命中。
partial class UserDataContext
{
public static UserDataContext Get()
{
var sqlConnection = new HelpSaudeAPDataContext().Connection;
var profiledConnection = new MvcMiniProfiler.Data.ProfiledDbConnection(new SqlConnection("UserConnectionString"), MiniProfiler.Current);
return new HelpSaudeAPDataContext(profiledConnection);
}
}
不幸的是,没有带有 var db 连接的单点存储库,我可以简单地传递 mvc mini profiler 连接。
var db = UserDataContext(profilerConnection);