views:

64

answers:

2

I am trying out some cascade options with nhibernate mapping and have a unit test where I'd like to use a tool to inspect the state of the database. I was hoping I could use linqpad to do this, but the connection seems hung while in the debugger. I'd seen a demo not to long ago where SSMS was being used to inspect the db during a debug, so I'm wondering if I should be able to somehow use linqpad or if I need a different tool (I haven't installed SSMS on my laptop and would prefer something more light weight).

Unrelated to linqpad, my motivation for doing this is I am not sure if the db state I'm validating in a unit test is from the db or from nhibernate's cache? If Session.Flush() is called before the the assert, does that mean a fetch in an assert is guaranteed to be coming from the db?

Cheers, Berryl

+1  A: 

To the second part of your question - Yes, calling session.flush() before any kind of fetch will push everything out to the DB. You could also do:

Transaction t = session.beginTransaction();
//some hibernate interaction test code
t.commit()
//you can rest assured that any code coming from the hibernate now will
//be exactly what is in the db.

hope that helps.

meiguoren
A: 

SQL Profiler (Tools > SQL Server Profile from SSMS) or NHProf will help you monitor commands sent to the database.

Jamie Ide
Hi JamieI can see sql statements sent to the db now just by configuring NHib to send them to the console. Its useful but I am looking for a lightweight tool that can inspect the db data during the debug.Cheers,
Berryl