Slide 47
Slide 47 text
public class LoggingDbProfiler : IDbProfiler
{
// 中略
// コマンドが完了された時に呼ばれる
public void ExecuteFinish(System.Data.IDbCommand pro
ExecuteType executeType, S
{
commandText = profiledDbCommand.CommandText;
if (executeType != ExecuteType.Reader)
{
stopwatch.Stop();
sqlLogger.Trace(Newtonsoft.Json.JsonConvert.
{
date = DateTime.Now,
command = executeType,
key = commandText,
ms = stopwatch.ElapsedMilliseconds
}, Newtonsoft.Json.Formatting.None));
}
}
}
MiniProfilerに用意されている
IDbProfilerをカスタムし
て,ADO.NETのコネクションとして
使うことで自由に仕込める
var conn = new
ProfiledDbConnection(new
SqlConnection(), new
LoggingDbProfiler());