2011-12-27 53 views
0

我試圖讓它在迷你探查記錄LINQ到SQL爲the documentation saysASP.net迷你探查LINQ到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' 

我refered到How can I make the ASP.NET MVC mini profiler work with Linq 2 SQL?,但沒有在那裏的解決方案似乎爲我工作。

任何人都可以告訴我如何讓它爲linq-to-sql工作嗎?如果你改變這個

+0

你是使用nuget還是來自最新來源? – 2011-12-28 01:29:54

+0

@sam是我使用nuget,我最近下載了二進制文件 – 2011-12-28 03:44:11

+0

你有沒有嘗試過新的ProfiledDbConnection(cnn,MiniProfiler.Current)? – 2011-12-29 10:18:53

回答

1

你的第二個experient應該工作:

ProfiledDbConnection.Get(...) 

...這樣的:

new ProfiledDbConnection(...) 

因此,你應該使用構造一個靜態的吸氣劑。

我認爲他們更改了v1和v2之間的ProfiledDbConnection的API,您仍然可以找到舊版本的示例代碼。