|
using System;
using System.Data;
namespace Demo {
public class Transaction : IDisposable {
private IDbConnection _DB;
private IDbTransaction _DBTransaction;
public IDbTransaction DBTransaction {
get { return _DBTransaction; }
}
public Transaction(IDbConnection aDB) : this(aDB, true) {
}
public Transaction(IDbConnection aDB, bool aHandle) {
if (aHandle) {
_DB = aDB;
_DBTransaction = _DB.BeginTransaction();
}
}
public void Commit() {
if (_DB != null) {
_DBTransaction.Commit();
_DBTransaction.Dispose();
_DB = null;
}
}
public void Dispose() {
if (_DB != null) {
_DBTransaction.Rollback();
_DBTransaction.Dispose();
_DB = null;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Chad Z. Hower, a.k.a. Kudzu
"Programming is an art form that fights back"
I am a former Microsoft Regional DPE (MEA) covering 85 countries, former Microsoft Regional Director, and 10 Year Microsoft MVP.
I have lived in Bulgaria, Canada, Cyprus, Switzerland, France, Jordan, Russia, Turkey, The Caribbean, and USA.
Creator of Indy, IntraWeb, COSMOS, X#, CrossTalk, and more.