NHibernate Statistics Queries not visible
I am trying to use the nHibernate IStatistics for my app. I have some code like this
IStatistics stats = GetSessionFactory().Statistics;
var query开发者_运维技巧Count = stats.QueryExecutionCount;
var queries = stats.Queries;
The queryCount is populated with a value for the number of queries but the queries string array is always empty. Is there a reason for this? I am using NHibernate 3.0.
Do this before running any queries:
stats.IsStatisticsEnabled = true;
After doing that, the following code:
session.CreateQuery("from Foo").List();
Console.WriteLine(stats.Queries[0]);
...will print "from Foo".
Only HQL Queries are stored (also LINQ, but just the string is not very useful)
精彩评论