ASP.net 迷你分析器 linq-to-sql
我试图让它在迷你分析器中将 linq-to-sql 记录为 文档说
我将其添加到我的App_Code/DataClasses.designer.cs
中,如下所示:
public MainContext() :
base(global::System.Configuration.ConfigurationManager.ConnectionStrings["ScirraConnectionString"].ConnectionString, mappingSource)
{
OnCreated();
}
// Code I'm adding in for the mini profiler
partial class DBContext
{
public static DBContext Get()
{
var conn = new MvcMiniProfiler.Data.ProfiledDbConnection(GetConnection(), MiniProfiler.Current);
return new DBContext(conn);
}
}
但它抛出错误:
The name 'GetConnection' does not exist in the current context
我也尝试过这个:
partial class DBContext
{
public static DBContext Get()
{
var conn = ProfiledDbConnection.Get(new System.Data.SqlClient.SqlConnection(global::System.Configuration.ConfigurationManager.ConnectionStrings["ScirraConnectionString"].ConnectionString));
return new DBContext(conn);
}
}
但它抛出
'MvcMiniProfiler.Data.ProfiledDbConnection' does not contain a definition for 'Get'
我提到的<一href="https://stackoverflow.com/questions/6296518/how-can-i-make-the-asp-net-mvc-mini-profiler-work-with-linq-2-sql">我该如何制作ASP.NET MVC 迷你分析器可以与 Linq 2 SQL 一起使用吗? 但其中的解决方案似乎都不适合我。
谁能告诉我如何让它适用于 linq-to-sql?
I'm trying to get it to record linq-to-sql in the mini profiler as the documentation says
I add this to my App_Code/DataClasses.designer.cs
as follows:
public MainContext() :
base(global::System.Configuration.ConfigurationManager.ConnectionStrings["ScirraConnectionString"].ConnectionString, mappingSource)
{
OnCreated();
}
// Code I'm adding in for the mini profiler
partial class DBContext
{
public static DBContext Get()
{
var conn = new MvcMiniProfiler.Data.ProfiledDbConnection(GetConnection(), MiniProfiler.Current);
return new DBContext(conn);
}
}
But it throws the error:
The name 'GetConnection' does not exist in the current context
I've also tried this:
partial class DBContext
{
public static DBContext Get()
{
var conn = ProfiledDbConnection.Get(new System.Data.SqlClient.SqlConnection(global::System.Configuration.ConfigurationManager.ConnectionStrings["ScirraConnectionString"].ConnectionString));
return new DBContext(conn);
}
}
But it throws
'MvcMiniProfiler.Data.ProfiledDbConnection' does not contain a definition for 'Get'
I've refered to How can I make the ASP.NET MVC mini profiler work with Linq 2 SQL? but none of the solutions in there seem to work for me.
Can anyone show me how I would get it working for linq-to-sql?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您将其更改为:...,则您的第二个体验应该可以工作
:
因此,您应该使用构造函数,而不是静态 getter。
我认为他们在 v1 和 v2 之间更改了 ProfiledDbConnection 的 API,并且您仍然可以找到旧版本的示例代码。
Your second experient should work if you change this:
...to this:
So instead of a static getter you should use the constructor.
I think they changed the API for ProfiledDbConnection somewhere between v1 and v2, and you can still find example code for the older version.