Skip to content

Commit

Permalink
Adding a switch to read from the data source without using a transact…
Browse files Browse the repository at this point in the history
…ion. This is useful for 'downlevel' ADO.NET providers like the OdbcConnection for dBase that does not support transactions.
  • Loading branch information
agross authored and ayende committed Feb 28, 2010
1 parent 6343f11 commit 7cc19b8
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions Rhino.Etl.Core/Operations/InputCommandOperation.cs
Expand Up @@ -17,6 +17,16 @@ public abstract class InputCommandOperation : AbstractCommandOperation
public InputCommandOperation(string connectionStringName)
: base(connectionStringName)
{
UseTransaction = true;
}

///<summary>
/// True, if the input operation should be run in a transaction. Otherwise,false.
///</summary>
public bool UseTransaction
{
get;
set;
}

/// <summary>
Expand All @@ -27,7 +37,7 @@ public InputCommandOperation(string connectionStringName)
public override IEnumerable<Row> Execute(IEnumerable<Row> rows)
{
using (IDbConnection connection = Use.Connection(ConnectionStringName))
using (IDbTransaction transaction = connection.BeginTransaction())
using (IDbTransaction transaction = BeginTransaction(connection))
{
using (currentCommand = connection.CreateCommand())
{
Expand All @@ -41,8 +51,20 @@ public override IEnumerable<Row> Execute(IEnumerable<Row> rows)
}
}
}
transaction.Commit();
if (transaction != null)
{
transaction.Commit();
}
}
}

IDbTransaction BeginTransaction(IDbConnection connection)
{
if (UseTransaction)
{
return connection.BeginTransaction();
}
return null;
}

/// <summary>
Expand All @@ -58,4 +80,4 @@ public override IEnumerable<Row> Execute(IEnumerable<Row> rows)
/// <param name="cmd">The command.</param>
protected abstract void PrepareCommand(IDbCommand cmd);
}
}
}

0 comments on commit 7cc19b8

Please sign in to comment.