2011-12-27 20 views
0

私は次のように私は私のApp_Code/DataClasses.designer.csにこれを追加することがthe documentation saysASP.netミニプロファイラLINQからSQLへ

としてミニプロファイラでLINQツーSQLを記録するために取得しようとしている:

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' 

を投げる私はHow can I make the ASP.NET MVC mini profiler work with Linq 2 SQL?に参照さましたが、そこでのソリューションのどれも私のために働くように見えるん。

誰でも私にそれをlinq-to-SQLのために働かせる方法を教えてもらえますか?

new ProfiledDbConnection(...) 

ので、代わりのあなたは、コンストラクタを使用する必要があり、静的ゲッター:これに...

ProfiledDbConnection.Get(...) 

+0

あなたはナゲットを使用していますか、最新のソースですか? –

+0

@samはい私はナゲットを使用しました。私は非常に最近、 –

+0

バイナリをダウンロードしましたあなたは新しいProfiledDbConnection(cnn、MiniProfiler.Current)を試しましたか? –

答えて

1

あなたの二Experient社は、あなたがこれを変更する場合は動作するはずです。

ProfiledDbConnectionのAPIをv1とv2の間のどこかに変更しても、以前のバージョンのサンプルコードを見つけることができます。