diff --git a/Rhino.Etl.Core/Operations/InputCommandOperation.cs b/Rhino.Etl.Core/Operations/InputCommandOperation.cs index 1769d70..f583710 100644 --- a/Rhino.Etl.Core/Operations/InputCommandOperation.cs +++ b/Rhino.Etl.Core/Operations/InputCommandOperation.cs @@ -17,6 +17,16 @@ public abstract class InputCommandOperation : AbstractCommandOperation public InputCommandOperation(string connectionStringName) : base(connectionStringName) { + UseTransaction = true; + } + + /// + /// True, if the input operation should be run in a transaction. Otherwise,false. + /// + public bool UseTransaction + { + get; + set; } /// @@ -27,7 +37,7 @@ public InputCommandOperation(string connectionStringName) public override IEnumerable Execute(IEnumerable rows) { using (IDbConnection connection = Use.Connection(ConnectionStringName)) - using (IDbTransaction transaction = connection.BeginTransaction()) + using (IDbTransaction transaction = BeginTransaction(connection)) { using (currentCommand = connection.CreateCommand()) { @@ -41,8 +51,20 @@ public override IEnumerable Execute(IEnumerable rows) } } } - transaction.Commit(); + if (transaction != null) + { + transaction.Commit(); + } + } + } + + IDbTransaction BeginTransaction(IDbConnection connection) + { + if (UseTransaction) + { + return connection.BeginTransaction(); } + return null; } /// @@ -58,4 +80,4 @@ public override IEnumerable Execute(IEnumerable rows) /// The command. protected abstract void PrepareCommand(IDbCommand cmd); } -} \ No newline at end of file +}