From docomentation of SessionManager.HasErrors
property:
/// <summary>
/// Gets or sets value indicating whether an error has occurred
/// on execution of the current request and transaction should be rollbacked.
/// </summary>
So it doesn't anything except ensuring the transaction for the current web request is rolled back @ its completion.
That's how it really works:
protected virtual Pair<Session, IDisposable> ProvideSession()
{
var newSession = Domain.OpenSession(); // Open, but don't activate!
var transactionScope = newSession.OpenTransaction();
var toDispose = transactionScope.Join(newSession);
return new Pair<Session, IDisposable>(newSession, new Disposable(disposing => {
try {
if (!HasErrors) // That's the only action it is responsible for
transactionScope.Complete();
}
finally {
toDispose.DisposeSafely();
}
}));
}
Thus if you'll set it to true
, you'll see the insertion in the SQL Profiler log, bug actually inserted entry won't appear in the DB - because of further rollback.
answered
Feb 20 '11 at 05:18
Alex Yakunin
2971●4●4●12