DatabaseErrorType Enumeration
The deferent types of errors
Namespace: Firefly.Box.Data.DataProviderAssembly: Firefly.Box (in Firefly.Box.dll) Version: debug-master-v:33791
public enum DatabaseErrorType
Public Enumeration DatabaseErrorType
This example demonstrates the usage of DatabaseErrorHandling
This example is in the form of Unit Tests. It references the NUnit framework. This framework can be downloaded from
www.NUnit.org. For more information about unit testing visit:
www.NUnit.org.
This example is based on test data. The code for the entities included in this test data can be found in the documentation of
Entityusing System;
using System.Collections.Generic;
using System.Text;
using Firefly.Box.Data.DataProvider;
using NUnit.Framework;
using Firefly.Box;
using Firefly.Box.Testing;
namespace TestFirefly.Box.Documentation
{
[TestFixture]
public class DatabaseErrorHandling
{
[Test]
public void DatabaseErrorHandlingEventSequence()
{
var jobs = new Pubs.Jobs();
jobs.InitializeWithTestData();
var bp = new BusinessProcess()
{
From = jobs,
Activity = Activities.Insert
};
string eventSequence = "";
bp.PreviewDatabaseError += e =>
{
eventSequence += "PreviewDatabaseError " + e.ErrorType + "\n";
e.HandlingStrategy = DatabaseErrorHandlingStrategy.Rollback;
};
bp.DatabaseErrorOccurred += e => eventSequence += "DatabaseErrorOccurred " + e.ErrorType + "\n";
var handler = bp.Handlers.AddDatabaseErrorHandler(DatabaseErrorType.DuplicateIndex);
handler.Invokes += e => eventSequence += "DatabaseErrorHandler " + e.ErrorType + "\n";
bp.ForFirstRow(() =>
{
jobs.Id.Value = 1;//Duplicate index error, because job with id 1 already exists
});
eventSequence.ShouldBe("PreviewDatabaseError DuplicateIndex\n" +
"DatabaseErrorHandler DuplicateIndex\n" +
"DatabaseErrorOccurred DuplicateIndex\n");
}
}
}
AllErrors | 0 |
Represents any and all errors
|
UnknownError | 1 |
An error that is not specificly defined
|
DuplicateIndex | 2 |
Occurs when values are updated or inserted to the database, and at least one of the unique contraints is violated
|
LockedRow | 3 |
An attempt to lock a row failed because the row is already locked by another session
|
DataChangeFailed | 4 |
An attempt to perform update, insert or delete failed for an unspecified reason
|
ConstraintFailed | 5 | |
RowDoesNotExist | 6 | |
RowWasChangedSinceLoaded | 7 | |
Deadlock | 8 | |
ReadOnlyEntityUpdate | 9 | |
TriggerFailed | 10 | |
NullInOnlyOnePartOfDateTimePair | 11 | |
FailedToInitializeEntity | 12 | |
InvalidSQLStatement | 13 | |
UpdatedRowWasChangedSinceLoaded | 14 | |
TransactionRolledBack | 15 | |