time to read 2 min | 389 words

Okay, I said it is not there yet, but I got annoyed by the lack of this feature, and I really had to make this work.

That one was a pretty tough one. It required me to make some minor modifications to NHiberante, as a result, this feature works with NHbierante r3976 or up only. What this means is that if you want to use this feature, you have to get it from the trunk.

This is the only feature in NH Prof that requires the trunk.

In this feature, we can see that we detect a cached query, and are able to display it properly.:

image

I am not sure how I should treat this for the purpose of analysis. Should this be grouped with the actual query? Should this be a separate entry?

Anyway, just for kicks, here is the test for the feature:

[TestFixture]
public class CachingTestFixture : IntegrationTestBase
{
    [Test]
    public void CanDetectCachedQueries()
    {
        ExecuteScenarioInDifferentAppDomain<UsingCacheQueries>();

    	var array = observer.Model.Sessions[2].Statements.OfType<StatementModel>()
    		.ToArray();
		Assert.AreEqual(@"Cached query: 
SELECT this_.Id             as Id7_0_,
   this_.Title          as Title7_0_,
   this_.Subtitle       as Subtitle7_0_,
   this_.AllowsComments as AllowsCo4_7_0_,
   this_.CreatedAt      as CreatedAt7_0_
FROM   Blogs this_
WHERE  this_.Title = 'The lazy blog' /* @p0 */
   and this_.Id = 1 /* @p1 */
", array[0].Text);
		Assert.AreEqual(@"Cached query: 
select blog0_.Id             as Id7_,
   blog0_.Title          as Title7_,
   blog0_.Subtitle       as Subtitle7_,
   blog0_.AllowsComments as AllowsCo4_7_,
   blog0_.CreatedAt      as CreatedAt7_
from   Blogs blog0_
where  ( blog0_.Title = 'The lazy blog' /* @p0 */ )
   and ( blog0_.Id = 1 /* @p1 */ )
", array[2].Text);
    }
}

As an aside, do you think that posting the tests is good? Should I just do the screen shots?