Ok, worked it out myself, with .NET 3.5 use anonymous methods.

e.g.
ISerial result = QueryProcessor.Linq(() => Session.Linq<ISerial>
().SingleOrDefault(s => s.SerialId == serialIdentifier));

and

public static T Linq<T>(Func<T> executeStatement)
{
        int retry = 0;
        T result = default(T);
        do
        {
                try
                {
                        result = executeStatement();
                        retry = RetryAttempts;
                }
                catch (ADOException ex)
                {
                        RetryADOException(ex, ref retry);
                }
                catch (Exception)
                {
                        throw;
                }
        } while (retry < RetryAttempts);

        return result;
}

where RetryADO Exception is logic to decide if the statement can be
retried (e.g. Deadlock).

My bigger question though... Is this a good idea?

The NH documentation states that ANY exception leaves the session in
an unknown state. I can understand for state state, data errors etc.
but what about database errors (memory, deadlock, connection lost
etc.). In many cases the advice is to resubmit. Regardless of any
potential logic errors, will the NH session be safe to reuse in these
specific DB error instances?

--~--~---------~--~----~------------~-------~--~----~
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