protected internal static object Execute(Type targetType, NHibernateDelegate call, object instance)
{
if (targetType == null) throw new ArgumentNullException("targetType", "Target type must be informed");
if (call == null) throw new ArgumentNullException("call", "Delegate must be passed");
EnsureInitialized(targetType);
ISession session = holder.CreateSession(targetType);
try
{
return call(session, instance);
}
catch (ValidationException)
{
holder.FailSession(session);
throw;
}
catch (Exception ex)
{
holder.FailSession(session);
throw new ActiveRecordException("Error performing Execute for " + targetType.Name, ex);
}
finally
{
holder.ReleaseSession(session);
}
}