怎样才能让使用LINQ 2 SQL的ASP.NET MVC迷你探查工作? [英] How can I make the ASP.NET MVC mini profiler work with Linq 2 SQL?
本文介绍了怎样才能让使用LINQ 2 SQL的ASP.NET MVC迷你探查工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
看起来真棒,但我却不能 ASP.NET MVC迷你探查得到LINQ的2 SQL使用示例。
The ASP.NET MVC Mini Profiler looks awesome, but I don't get the Linq 2 SQL usage example.
这是从探查文档LINQ2SQL例如:
This is the Linq2SQL example from the profiler documentation:
partial class DBContext
{
public static DBContext Get()
{
var conn = ProfiledDbConnection.Get(GetConnection());
return new DBContext(conn);
// or: return DataContextUtils.CreateDataContext<DBContext>(conn);
}
}
如何在我的实际应用程序中使用呢?我本来期望某种在我的DataContext的包装的,但这似乎以不同的方式工作。我甚至不知道其中定义了的getConnection()从实例方法。
How do I use this in my actual application? I would have expected some kind of wrapper around my DataContext, but this seems to work in a different way. I don't even know where that that "GetConnection()" method from the example is defined.
谢谢,
阿德里安
推荐答案
终于想通了。万一别人有同样的问题:
Finally figured it out. In case someone else has the same question:
private static DataClassesDataContext CreateNewContext()
{
var sqlConnection = new SqlConnection(<myconnectionstring>);
var profiledConnection = ProfiledDbConnection.Get(sqlConnection);
return DataContextUtils.CreateDataContext<DataClassesDataContext>(profiledConnection);
}
这篇关于怎样才能让使用LINQ 2 SQL的ASP.NET MVC迷你探查工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文