Hello,
There are 2 primary ways of doing the task. First is to use DbCommandEventWatcherService
like this:
watcher = (DbCommandEventWatcherService) session.GetService(typeof (DbCommandEventWatcherService));
Query q = session.CreateQuery(request.Text);
watcher.StartCapture();
QueryResult qr = q.Execute();
watcher.StopCapture();
foreach(DbCommandExecutionEventArgs item in watcher.DbCommandExecutionLog) {
Console.WriteLine(item.CommandText);
}
The second way is to utilize System.Reflection and obtain value of QueryBase.command
field.
answered
Sep 29 '11 at 03:14
Dmitri Maximov
2211●1●2●11