Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare the database before loading rows #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ Rhino.Etl.nuspec
*.nupkg
/Rhino-Etl-Cmd.nuspec
Tools/xUnit/Aggregate.*
Tools/xUnit/users.txt
Tools/xUnit/users.txt
.vs
10 changes: 10 additions & 0 deletions Rhino.Etl.Core/Operations/OutputCommandOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public override IEnumerable<Row> Execute(IEnumerable<Row> rows)
using (IDbConnection connection = Use.Connection(ConnectionStringSettings))
using (IDbTransaction transaction = BeginTransaction(connection))
{
PrepareDatabase(connection, transaction);
foreach (Row row in new SingleRowEventRaisingEnumerator(this, rows))
{
using (IDbCommand cmd = connection.CreateCommand())
Expand Down Expand Up @@ -71,5 +72,14 @@ public override IEnumerable<Row> Execute(IEnumerable<Row> rows)
/// <param name="cmd">The command.</param>
/// <param name="row">The row.</param>
protected abstract void PrepareCommand(IDbCommand cmd, Row row);

/// <summary>
/// Prepares the database before loading rows.
/// </summary>
/// <param name="connection">The connection.</param>
/// <param name="transaction">The transaction.</param>
protected virtual void PrepareDatabase(IDbConnection connection, IDbTransaction transaction)
{
}
}
}