开发者

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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜