forked from ayende/rhino-etl
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote branch 'upstream/master'
- Loading branch information
Showing
75 changed files
with
3,408 additions
and
2,909 deletions.
There are no files selected for viewing
109 changes: 60 additions & 49 deletions
109
Rhino.Etl.Core/ConventionOperations/ConventionInputCommandOperation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,61 @@ | ||
namespace Rhino.Etl.Core.ConventionOperations | ||
{ | ||
using System.Data; | ||
using Operations; | ||
|
||
/// <summary> | ||
/// A convention based version of <see cref="InputCommandOperation"/>. Will | ||
/// figure out as many things as it can on its own. | ||
/// </summary> | ||
public class ConventionInputCommandOperation : InputCommandOperation | ||
{ | ||
private string command; | ||
|
||
/// <summary> | ||
/// Gets or sets the command to get the input from the database | ||
/// </summary> | ||
public string Command | ||
{ | ||
get { return command; } | ||
set { command = value; } | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ConventionInputCommandOperation"/> class. | ||
/// </summary> | ||
/// <param name="connectionStringName">Name of the connection string.</param> | ||
public ConventionInputCommandOperation(string connectionStringName) : base(connectionStringName) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Creates a row from the reader. | ||
/// </summary> | ||
/// <param name="reader">The reader.</param> | ||
/// <returns></returns> | ||
protected override Row CreateRowFromReader(IDataReader reader) | ||
{ | ||
return Row.FromReader(reader); | ||
} | ||
|
||
/// <summary> | ||
/// Prepares the command for execution, set command text, parameters, etc | ||
/// </summary> | ||
/// <param name="cmd">The command.</param> | ||
protected override void PrepareCommand(IDbCommand cmd) | ||
{ | ||
cmd.CommandText = Command; | ||
} | ||
} | ||
using System.Configuration; | ||
|
||
namespace Rhino.Etl.Core.ConventionOperations | ||
{ | ||
using System.Data; | ||
using Operations; | ||
|
||
/// <summary> | ||
/// A convention based version of <see cref="InputCommandOperation"/>. Will | ||
/// figure out as many things as it can on its own. | ||
/// </summary> | ||
public class ConventionInputCommandOperation : InputCommandOperation | ||
{ | ||
private string command; | ||
|
||
/// <summary> | ||
/// Gets or sets the command to get the input from the database | ||
/// </summary> | ||
public string Command | ||
{ | ||
get { return command; } | ||
set { command = value; } | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ConventionInputCommandOperation"/> class. | ||
/// </summary> | ||
/// <param name="connectionStringName">Name of the connection string.</param> | ||
public ConventionInputCommandOperation(string connectionStringName) : this(ConfigurationManager.ConnectionStrings[connectionStringName]) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ConventionInputCommandOperation"/> class. | ||
/// </summary> | ||
/// <param name="connectionStringSettings">Name of the connection string.</param> | ||
public ConventionInputCommandOperation(ConnectionStringSettings connectionStringSettings) | ||
: base(connectionStringSettings) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Creates a row from the reader. | ||
/// </summary> | ||
/// <param name="reader">The reader.</param> | ||
/// <returns></returns> | ||
protected override Row CreateRowFromReader(IDataReader reader) | ||
{ | ||
return Row.FromReader(reader); | ||
} | ||
|
||
/// <summary> | ||
/// Prepares the command for execution, set command text, parameters, etc | ||
/// </summary> | ||
/// <param name="cmd">The command.</param> | ||
protected override void PrepareCommand(IDbCommand cmd) | ||
{ | ||
cmd.CommandText = Command; | ||
} | ||
} | ||
} |
123 changes: 67 additions & 56 deletions
123
Rhino.Etl.Core/ConventionOperations/ConventionOutputCommandOperation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,68 @@ | ||
namespace Rhino.Etl.Core.ConventionOperations | ||
{ | ||
using System; | ||
using System.Collections; | ||
using System.Data; | ||
using Operations; | ||
|
||
/// <summary> | ||
/// A convention based version of <see cref="OutputCommandOperation"/>. Will | ||
/// figure out as many things as it can on its own. | ||
/// </summary> | ||
public class ConventionOutputCommandOperation : OutputCommandOperation | ||
{ | ||
private string command; | ||
|
||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ConventionOutputCommandOperation"/> class. | ||
/// </summary> | ||
/// <param name="connectionStringName">Name of the connection string.</param> | ||
public ConventionOutputCommandOperation(string connectionStringName) | ||
: base(connectionStringName) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the command to execute against the database | ||
/// </summary> | ||
public string Command | ||
{ | ||
get { return command; } | ||
set { command = value; } | ||
} | ||
|
||
/// <summary> | ||
/// Prepares the row by executing custom logic before passing on to the <see cref="PrepareCommand"/> | ||
/// for further process. | ||
/// </summary> | ||
/// <param name="row">The row.</param> | ||
protected virtual void PrepareRow(Row row) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Prepares the command for execution, set command text, parameters, etc | ||
/// </summary> | ||
/// <param name="cmd">The command.</param> | ||
/// <param name="row">The row.</param> | ||
protected override void PrepareCommand(IDbCommand cmd, Row row) | ||
{ | ||
PrepareRow(row); | ||
cmd.CommandText = Command; | ||
CopyRowValuesToCommandParameters(currentCommand, row); | ||
} | ||
|
||
} | ||
using System.Configuration; | ||
|
||
namespace Rhino.Etl.Core.ConventionOperations | ||
{ | ||
using System; | ||
using System.Collections; | ||
using System.Data; | ||
using Operations; | ||
|
||
/// <summary> | ||
/// A convention based version of <see cref="OutputCommandOperation"/>. Will | ||
/// figure out as many things as it can on its own. | ||
/// </summary> | ||
public class ConventionOutputCommandOperation : OutputCommandOperation | ||
{ | ||
private string command; | ||
|
||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ConventionOutputCommandOperation"/> class. | ||
/// </summary> | ||
/// <param name="connectionStringName">Name of the connection string.</param> | ||
public ConventionOutputCommandOperation(string connectionStringName) | ||
: this(ConfigurationManager.ConnectionStrings[connectionStringName]) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ConventionOutputCommandOperation"/> class. | ||
/// </summary> | ||
/// <param name="connectionStringSettings">Connection string settings to use.</param> | ||
public ConventionOutputCommandOperation(ConnectionStringSettings connectionStringSettings) | ||
: base(connectionStringSettings) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the command to execute against the database | ||
/// </summary> | ||
public string Command | ||
{ | ||
get { return command; } | ||
set { command = value; } | ||
} | ||
|
||
/// <summary> | ||
/// Prepares the row by executing custom logic before passing on to the <see cref="PrepareCommand"/> | ||
/// for further process. | ||
/// </summary> | ||
/// <param name="row">The row.</param> | ||
protected virtual void PrepareRow(Row row) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Prepares the command for execution, set command text, parameters, etc | ||
/// </summary> | ||
/// <param name="cmd">The command.</param> | ||
/// <param name="row">The row.</param> | ||
protected override void PrepareCommand(IDbCommand cmd, Row row) | ||
{ | ||
PrepareRow(row); | ||
cmd.CommandText = Command; | ||
CopyRowValuesToCommandParameters(currentCommand, row); | ||
} | ||
|
||
} | ||
} |
119 changes: 64 additions & 55 deletions
119
Rhino.Etl.Core/ConventionOperations/ConventionSqlBulkInsertOperation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,65 @@ | ||
using System; | ||
using Rhino.Etl.Core.Operations; | ||
|
||
namespace Rhino.Etl.Core.ConventionOperations | ||
{ | ||
/// <summary>Convertion wrapper around the <see cref="SqlBulkInsertOperation"/>.</summary> | ||
public class ConventionSqlBulkInsertOperation : SqlBulkInsertOperation | ||
{ | ||
/// <summary>Creates a new <see cref="ConventionSqlBulkInsertOperation"/></summary> | ||
/// <param name="connectionStringName"></param> | ||
/// <param name="targetTable"></param> | ||
public ConventionSqlBulkInsertOperation(string connectionStringName, string targetTable) : base(connectionStringName, targetTable) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Prepares the schema of the target table | ||
/// </summary> | ||
protected override void PrepareSchema() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Prepares the mapping for use, by default, it uses the schema mapping. | ||
/// This is the preferred appraoch | ||
/// </summary> | ||
public override void PrepareMapping() | ||
{ | ||
} | ||
|
||
/// <summary>Adds a column to the destination mapping.</summary> | ||
/// <param name="destinationColumn">The name of column, this is case sensitive.</param> | ||
public virtual void MapColumn(string destinationColumn) | ||
{ | ||
MapColumn(destinationColumn, typeof (string)); | ||
} | ||
|
||
/// <summary>Adds a column and specified type to the destination mapping.</summary> | ||
/// <param name="destinationColumn">The name of the column</param> | ||
/// <param name="columnType">The type of the column.</param> | ||
public virtual void MapColumn(string destinationColumn, Type columnType) | ||
{ | ||
MapColumn(destinationColumn, destinationColumn, columnType); | ||
} | ||
|
||
/// <summary>Adds a column and the specified type to the destination mapping with the given sourceColumn mapping.</summary> | ||
/// <param name="destinationColumn"></param> | ||
/// <param name="columnType"></param> | ||
/// <param name="sourceColumn"></param> | ||
public virtual void MapColumn(string destinationColumn, string sourceColumn, Type columnType) | ||
{ | ||
Schema[destinationColumn] = columnType; | ||
Mappings[sourceColumn] = destinationColumn; | ||
} | ||
} | ||
using System; | ||
using System.Configuration; | ||
using Rhino.Etl.Core.Operations; | ||
|
||
namespace Rhino.Etl.Core.ConventionOperations | ||
{ | ||
/// <summary>Convertion wrapper around the <see cref="SqlBulkInsertOperation"/>.</summary> | ||
public class ConventionSqlBulkInsertOperation : SqlBulkInsertOperation | ||
{ | ||
/// <summary>Creates a new <see cref="ConventionSqlBulkInsertOperation"/></summary> | ||
/// <param name="connectionStringName"></param> | ||
/// <param name="targetTable"></param> | ||
public ConventionSqlBulkInsertOperation(string connectionStringName, string targetTable) : this(ConfigurationManager.ConnectionStrings[connectionStringName], targetTable) | ||
{ | ||
} | ||
|
||
/// <summary>Creates a new <see cref="ConventionSqlBulkInsertOperation"/></summary> | ||
/// <param name="connectionStringSettings">Connection string settings to use.</param> | ||
/// <param name="targetTable"></param> | ||
public ConventionSqlBulkInsertOperation(ConnectionStringSettings connectionStringSettings, string targetTable) | ||
: base(connectionStringSettings, targetTable) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Prepares the schema of the target table | ||
/// </summary> | ||
protected override void PrepareSchema() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Prepares the mapping for use, by default, it uses the schema mapping. | ||
/// This is the preferred appraoch | ||
/// </summary> | ||
public override void PrepareMapping() | ||
{ | ||
} | ||
|
||
/// <summary>Adds a column to the destination mapping.</summary> | ||
/// <param name="destinationColumn">The name of column, this is case sensitive.</param> | ||
public virtual void MapColumn(string destinationColumn) | ||
{ | ||
MapColumn(destinationColumn, typeof (string)); | ||
} | ||
|
||
/// <summary>Adds a column and specified type to the destination mapping.</summary> | ||
/// <param name="destinationColumn">The name of the column</param> | ||
/// <param name="columnType">The type of the column.</param> | ||
public virtual void MapColumn(string destinationColumn, Type columnType) | ||
{ | ||
MapColumn(destinationColumn, destinationColumn, columnType); | ||
} | ||
|
||
/// <summary>Adds a column and the specified type to the destination mapping with the given sourceColumn mapping.</summary> | ||
/// <param name="destinationColumn"></param> | ||
/// <param name="columnType"></param> | ||
/// <param name="sourceColumn"></param> | ||
public virtual void MapColumn(string destinationColumn, string sourceColumn, Type columnType) | ||
{ | ||
Schema[destinationColumn] = columnType; | ||
Mappings[sourceColumn] = destinationColumn; | ||
} | ||
} | ||
} |
Oops, something went wrong.