I'm using NHibernate with SQL Server 2005 in a WPF client application.

If I manually stop the SQL Server service then restart it the session
doesn't automatically reconnect.

So far this seems to work but is there a better/cleaner way ? :

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 ?

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to