4
我擡頭How could I instantiate a Profiled DataAdapter to use with MVC MINI PROFILER?但這也沒有回答我的問題。如何掛接SqlDataAdapter到配置文件數據庫操作與mvc迷你配置文件
我在SqlDataSource的類像這樣的代碼 -
protected SqlCommand sqlCommand;
public SqlDatasource(String query, String connectionString) : this(connectionString)
{
this.sqlCommand.CommandText = query;
}
public DataTable getResults()
{
DataTable table = new DataTable();
SqlDataAdapter adapter = new SqlDataAdapter(this.sqlCommand);
SqlCommandBuilder commandBuilder = new SqlCommandBuilder(adapter);
adapter.Fill(table);
return table;
}
我想要的方式掛接到SqlDataAdapter的時候getResults()被調用。我搜查了很多,但似乎還沒有辦法讓我這樣做。
謝謝。
我應該提到,我在一個Nunit測試項目中使用它,所以我嘲笑了httpcontext,並且我沒有web.config。 –
好吧,現在我可以掛鉤ado.net,因爲我能夠得到一個sqlconnection的包裝。但是剖析器仍然沒有記錄sql時序。這是因爲HasSqlTimings設置爲false。我必須專門設置爲True嗎? –
這是一個錯誤,並已修復 - 請參閱http://stackoverflow.com/questions/22171922/miniprofiler-profileddbdataadapter –