-
Notifications
You must be signed in to change notification settings - Fork 595
Transactions
Wade Baglin edited this page Jan 24, 2016
·
9 revisions
PetaPoco supports all forms of ADO.net transactions and includes its own dept tracking (nesting) transaction support.
var db = config.Build()
.UsingConnectionString("cs")
.UsingProvider<SqlServerDatabaseProvider>()
.UsingIsolationLevel(IsolationLevel.Chaos)
.Create();
var db = new Database("MyConnectionStringName") { IsolationLevel = IsolationLevel.Chaos };
var db = new Database();
try
{
db.BeginTransaction();
// Some transactional DB work
db.CompleteTransaction();
}
catch (Exception e)
{
db.AbortTransaction();
}
var db = new Database();
using (var transaction = db.GetTransaction())
{
// Some transactional DB work
transaction.Complete();
}
var config = DatabaseConfiguration
.Build()
.UsingCommandTimeout(180);
using (TransactionScope scope = new TransactionScope())
{
var db = config.Create();
// Some transactional DB work
scope.Complete();
}
PetaPoco is proudly maintained by the Collaborating Platypus group and originally the brainchild of Brad Robinson