public MergeCommand(SqlTableSchema sourceTableSchema, SqlTableSchema targetTableSchema) { if (sourceTableSchema == null) throw new ArgumentNullException("sourceTableSchema"); if (targetTableSchema == null) throw new ArgumentNullException("targetTableSchema"); _sourceTableSchema = sourceTableSchema; _targetTableSchema = targetTableSchema; }
protected UpserterBase(SqlTableSchema targetTableSchema) { if (targetTableSchema == null) { throw new ArgumentNullException("targetTableSchema"); } TargetTableSchema = targetTableSchema; }
protected Dictionary <int, int> PerformUpsert(SqlConnection connection, ICollection <string> columnNames, IDataReader dataReader) { SqlTableSchema tempTableSchema = GetTempTableSchema(TargetTableSchema, columnNames); using (var upsert = new Upsert(connection, TargetTableSchema, tempTableSchema, columnNames)) { return(upsert.Execute(dataReader)); } }
public TypedUpserter(SqlTableSchema targetTableSchema, Dictionary <string, Func <T, object> > columnMappings, Action <T, int> identUpdater) : base(targetTableSchema) { if (columnMappings == null) { throw new ArgumentNullException("columnMappings"); } _columnMappings = columnMappings; _identUpdater = identUpdater; }
public Upsert(SqlConnection connection, SqlTableSchema targetTableSchema, SqlTableSchema tempTableSchema, ICollection<string> columnNames) { if (connection == null) throw new ArgumentNullException("connection"); if (targetTableSchema == null) throw new ArgumentNullException("targetTableSchema"); if (tempTableSchema == null) throw new ArgumentNullException("tempTableSchema"); if (columnNames == null) throw new ArgumentNullException("columnNames"); _connection = connection; _targetTableSchema = targetTableSchema; _tempTableSchema = tempTableSchema; _columnNames = columnNames; }
private void VerifyDataTable(DataTable dataTable, SqlTableSchema targetTableSchema) { // Ensure all columns in DataTable are in actual table schema foreach (DataColumn dataColumn in dataTable.Columns) { if (!targetTableSchema.Columns.Any(c => c.Name == dataColumn.ColumnName)) throw new Exception(String.Format("Column does not appear in table {0}", dataColumn.ColumnName)); } // ensure primary key columns present in data table if (!targetTableSchema.PrimaryKeyColumns.All(c => dataTable.Columns.Contains(c.Name))) throw new Exception("Table primary key columns must feature in DataTable"); }
public MergeCommand(SqlTableSchema sourceTableSchema, SqlTableSchema targetTableSchema) { if (sourceTableSchema == null) { throw new ArgumentNullException("sourceTableSchema"); } if (targetTableSchema == null) { throw new ArgumentNullException("targetTableSchema"); } _sourceTableSchema = sourceTableSchema; _targetTableSchema = targetTableSchema; }
private void VerifyDataTable(DataTable dataTable, SqlTableSchema targetTableSchema) { // Ensure all columns in DataTable are in actual table schema foreach (DataColumn dataColumn in dataTable.Columns) { if (!targetTableSchema.Columns.Any(c => c.Name == dataColumn.ColumnName)) { throw new Exception(String.Format("Column does not appear in table {0}", dataColumn.ColumnName)); } } // ensure primary key columns present in data table if (!targetTableSchema.PrimaryKeyColumns.All(c => dataTable.Columns.Contains(c.Name))) { throw new Exception("Table primary key columns must feature in DataTable"); } }
private SqlTableSchema GetTempTableSchema(SqlTableSchema targetTableSchema, ICollection<string> columnNames) { // only columns we're inserting var tempTableColumnList = targetTableSchema.Columns .Where(c => columnNames.Contains(c.Name)) .Select(c => { var tempCol = c.Clone(); tempCol.Nullable = true; return tempCol; }) .ToList(); // Add surrogate identity for temp table tempTableColumnList.Insert(0, new IdentityColumn()); // prepare temp table schema return new SqlTableSchema("#upsert", tempTableColumnList); }
private SqlTableSchema GetTempTableSchema(SqlTableSchema targetTableSchema, ICollection <string> columnNames) { // only columns we're inserting var tempTableColumnList = targetTableSchema.Columns .Where(c => columnNames.Contains(c.Name)) .Select(c => { var tempCol = c.Clone(); tempCol.Nullable = true; return(tempCol); }) .ToList(); // Add surrogate identity for temp table tempTableColumnList.Insert(0, new IdentityColumn()); // prepare temp table schema return(new SqlTableSchema("#upsert", tempTableColumnList)); }
public Upsert(SqlConnection connection, SqlTableSchema targetTableSchema, SqlTableSchema tempTableSchema, ICollection <string> columnNames) { if (connection == null) { throw new ArgumentNullException("connection"); } if (targetTableSchema == null) { throw new ArgumentNullException("targetTableSchema"); } if (tempTableSchema == null) { throw new ArgumentNullException("tempTableSchema"); } if (columnNames == null) { throw new ArgumentNullException("columnNames"); } _connection = connection; _targetTableSchema = targetTableSchema; _tempTableSchema = tempTableSchema; _columnNames = columnNames; }
protected UpserterBase(SqlTableSchema targetTableSchema) { if (targetTableSchema == null) throw new ArgumentNullException("targetTableSchema"); TargetTableSchema = targetTableSchema; }
public DataTableUpserter(SqlTableSchema targetTableSchema) : base(targetTableSchema) { }