I'm using NHibernate with SQL Server 2005 in a WPF client application.
If I manually stop the SQL Server service and then restart it the session doesn't automatically reconnect.
So far I'm doing this witch seems to work :
try
{
using (ITransaction transaction = this.Session.BeginTransaction())
{
// some select here
}
}catch(Exception ex)
{
if(this.Session.Connection.State == ConnectionState.Closed)
{
try
{
this.Session.Connection.Open();
}
catch (Exception)
{
}
}
}
Is there a better way ?