public SqlServerInsertBatchTable(SqlServerDataSourceBase dataSource, SqlServerObjectName tableName, DbDataReader dataReader, SqlServerObjectName tableTypeName, InsertOptions options) : base(dataSource) { m_Source = dataReader; m_Options = options; m_Table = dataSource.DatabaseMetadata.GetTableOrView(tableName); m_TableType = dataSource.DatabaseMetadata.GetUserDefinedTableType(tableTypeName); }
public void HashCodeTest(string nameA, string nameB) { var a = new SqlServerObjectName(nameA); var b = new SqlServerObjectName(nameB); Assert.AreEqual(a.GetHashCode(), b.GetHashCode(), "Hash codes do not match"); }
public void EqualityTest(string nameA, string nameB, bool expectedResult) { var a = new SqlServerObjectName(nameA); var b = new SqlServerObjectName(nameB); Assert.AreEqual(expectedResult, a.Equals(b)); Assert.AreEqual(expectedResult, SqlServerObjectName.Equals(a, b)); }
/// <summary> /// Initializes a new instance of the <see cref="SqlServerProcedureCall"/> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="procedureName">Name of the procedure.</param> /// <param name="argumentValue">The argument value.</param> internal SqlServerProcedureCall(SqlServerDataSourceBase dataSource, SqlServerObjectName procedureName, object?argumentValue) : base(dataSource, argumentValue) { if (procedureName == SqlServerObjectName.Empty) { throw new ArgumentException($"{nameof(procedureName)} is empty", nameof(procedureName)); } m_Procedure = DataSource.DatabaseMetadata.GetStoredProcedure(procedureName); }
/// <summary> /// Initializes a new instance of the <see cref="OleDbSqlServerDeleteSet" /> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="tableName">Name of the table.</param> /// <param name="whereClause">The where clause.</param> /// <param name="parameters">The parameters.</param> /// <param name="expectedRowCount">The expected row count.</param> /// <param name="options">The options.</param> public OleDbSqlServerDeleteSet(OleDbSqlServerDataSourceBase dataSource, SqlServerObjectName tableName, string whereClause, IEnumerable <OleDbParameter> parameters, int?expectedRowCount, DeleteOptions options) : base(dataSource, whereClause, parameters, expectedRowCount, options) { if (options.HasFlag(DeleteOptions.UseKeyAttribute)) { throw new NotSupportedException("Cannot use Key attributes with this operation."); } m_Table = dataSource.DatabaseMetadata.GetTableOrView(tableName); }
/// <summary> /// Initializes a new instance of the <see cref="OleDbSqlServerTableOrView{TObject}"/> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="tableOrViewName">Name of the table or view.</param> /// <param name="whereClause">The where clause.</param> /// <param name="argumentValue">The argument value.</param> public OleDbSqlServerTableOrView(OleDbSqlServerDataSourceBase dataSource, SqlServerObjectName tableOrViewName, string?whereClause, object?argumentValue) : base(dataSource) { if (tableOrViewName == SqlServerObjectName.Empty) { throw new ArgumentException($"{nameof(tableOrViewName)} is empty", nameof(tableOrViewName)); } m_ArgumentValue = argumentValue; m_WhereClause = whereClause; m_Table = DataSource.DatabaseMetadata.GetTableOrView(tableOrViewName); }
public SqlServerInsertBatch(SqlServerDataSourceBase dataSource, SqlServerObjectName tableName, DbDataReader dataReader, SqlServerObjectName tableTypeName, InsertOptions options) : base(dataSource) { m_Source = dataReader; m_Options = options; m_Table = dataSource.DatabaseMetadata.GetTableOrView(tableName); m_TableType = dataSource.DatabaseMetadata.GetUserDefinedType(tableTypeName); if (!m_TableType.IsTableType) { throw new MappingException($"{m_TableType.Name} is not a user defined table type"); } }
/// <summary> /// Initializes a new instance of the <see cref="OleDbSqlServerUpdateSet" /> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="tableName">Name of the table.</param> /// <param name="newValues">The new values.</param> /// <param name="options">The options.</param> /// <exception cref="System.NotSupportedException">Cannot use Key attributes with this operation.</exception> public OleDbSqlServerUpdateSet(OleDbSqlServerDataSourceBase dataSource, SqlServerObjectName tableName, object?newValues, UpdateOptions options) : base(dataSource) { if (options.HasFlag(UpdateOptions.UseKeyAttribute)) { throw new NotSupportedException("Cannot use Key attributes with this operation."); } m_Table = dataSource.DatabaseMetadata.GetTableOrView(tableName); m_NewValues = newValues; m_Options = options; }
/// <summary> /// Initializes a new instance of the <see cref="OleDbSqlServerTableOrView{TObject}" /> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="tableOrViewName">Name of the table or view.</param> /// <param name="filterValue">The filter value.</param> /// <param name="filterOptions">The filter options.</param> /// <exception cref="System.ArgumentException"></exception> public OleDbSqlServerTableOrView(OleDbSqlServerDataSourceBase dataSource, SqlServerObjectName tableOrViewName, object filterValue, FilterOptions filterOptions = FilterOptions.None) : base(dataSource) { if (tableOrViewName == SqlServerObjectName.Empty) { throw new ArgumentException($"{nameof(tableOrViewName)} is empty", nameof(tableOrViewName)); } m_FilterValue = filterValue; m_FilterOptions = filterOptions; m_Table = DataSource.DatabaseMetadata.GetTableOrView(tableOrViewName); }
/// <summary> /// Initializes a new instance of the <see cref="OleDbSqlServerUpdateSet" /> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="tableName">Name of the table.</param> /// <param name="updateExpression">The update expression.</param> /// <param name="updateArgumentValue">The update argument value.</param> /// <param name="options">The options.</param> /// <exception cref="System.NotSupportedException">Cannot use Key attributes with this operation.</exception> public OleDbSqlServerUpdateSet(OleDbSqlServerDataSourceBase dataSource, SqlServerObjectName tableName, string?updateExpression, object?updateArgumentValue, UpdateOptions options) : base(dataSource) { if (options.HasFlag(UpdateOptions.UseKeyAttribute)) { throw new NotSupportedException("Cannot use Key attributes with this operation."); } m_Table = dataSource.DatabaseMetadata.GetTableOrView(tableName); m_UpdateExpression = updateExpression; m_Options = options; m_UpdateArgumentValue = updateArgumentValue; }
/// <summary> /// Initializes a new instance of the <see cref="SqlServerDeleteMany" /> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="tableName">Name of the table.</param> /// <param name="whereClause">The where clause.</param> /// <param name="parameters">The parameters.</param> /// <param name="options">The options.</param> public SqlServerDeleteMany(SqlServerDataSourceBase dataSource, SqlServerObjectName tableName, string whereClause, IEnumerable <SqlParameter> parameters, DeleteOptions options) : base(dataSource) { if (options.HasFlag(DeleteOptions.UseKeyAttribute)) { throw new NotSupportedException("Cannot use Key attributes with this operation."); } m_Table = dataSource.DatabaseMetadata.GetTableOrView(tableName); m_WhereClause = whereClause; //m_Options = options; m_Parameters = parameters; }
/// <summary> /// Initializes a new instance of the <see cref="OleDbSqlServerUpdateSet" /> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="tableName">Name of the table.</param> /// <param name="newValues">The new values.</param> /// <param name="whereClause">The where clause.</param> /// <param name="parameters">The parameters.</param> /// <param name="expectedRowCount">The expected row count.</param> /// <param name="options">The options.</param> public OleDbSqlServerUpdateSet(OleDbSqlServerDataSourceBase dataSource, SqlServerObjectName tableName, object?newValues, string?whereClause, IEnumerable <OleDbParameter> parameters, int?expectedRowCount, UpdateOptions options) : base(dataSource) { if (options.HasFlag(UpdateOptions.UseKeyAttribute)) { throw new NotSupportedException("Cannot use Key attributes with this operation."); } m_Table = dataSource.DatabaseMetadata.GetTableOrView(tableName); m_NewValues = newValues; m_WhereClause = whereClause; m_ExpectedRowCount = expectedRowCount; m_Options = options; m_Parameters = parameters; }
internal SqlServerInsertBulk(SqlServerDataSourceBase dataSource, SqlServerObjectName tableName, IDataReader dataReader) : base(dataSource) { if (dataSource == null) { throw new ArgumentNullException(nameof(dataSource), $"{nameof(dataSource)} is null."); } if (dataReader == null) { throw new ArgumentNullException(nameof(dataReader), $"{nameof(dataReader)} is null."); } m_DataSource = dataSource; m_Source = dataReader; m_Table = dataSource.DatabaseMetadata.GetTableOrView(tableName); if (!m_Table.IsTable) { throw new MappingException($"Cannot perform a bulk insert into the view {m_Table.Name}"); } }
public SqlServerInsertBatch(SqlServerDataSourceBase dataSource, SqlServerObjectName tableName, IEnumerable <TObject> objects, InsertOptions options) : base(dataSource) { if (dataSource == null) { throw new ArgumentNullException(nameof(dataSource), $"{nameof(dataSource)} is null."); } var sourceList = objects.AsReadOnlyList(); if (sourceList == null || sourceList.Count == 0) { throw new ArgumentException($"{nameof(objects)} is null or empty.", nameof(objects)); } if (sourceList.Count > 1000) { throw new ArgumentException($"{nameof(objects)}.Count exceeds SQL Server's row count limit of 1000. Supply a table type, break the call into batches of 1000, use InsertMultipleBatch, or use BulkInsert.", nameof(objects)); } m_SourceList = sourceList; m_Options = options; m_Table = dataSource.DatabaseMetadata.GetTableOrView(tableName); }
public SqlServerInsertBulk InsertBulk(SqlServerObjectName tableName, IDataReader dataReader, SqlBulkCopyOptions options) { return(InsertBulk(tableName, dataReader).WithOptions(options)); }
/// <summary> /// Initializes a new instance of the <see cref="OleDbSqlServerDeleteSet"/> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="tableName">Name of the table.</param> /// <param name="whereClause">The where clause.</param> /// <param name="argumentValue">The argument value.</param> public OleDbSqlServerDeleteSet(OleDbSqlServerDataSourceBase dataSource, SqlServerObjectName tableName, string whereClause, object?argumentValue) : base(dataSource, whereClause, argumentValue) { m_Table = dataSource.DatabaseMetadata.GetTableOrView(tableName); }
/// <summary> /// Initializes a new instance of the <see cref="OleDbSqlServerDeleteSet"/> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="tableName">Name of the table.</param> /// <param name="filterValue">The filter value.</param> /// <param name="filterOptions">The options.</param> public OleDbSqlServerDeleteSet(OleDbSqlServerDataSourceBase dataSource, SqlServerObjectName tableName, object filterValue, FilterOptions filterOptions) : base(dataSource, filterValue, filterOptions) { m_Table = dataSource.DatabaseMetadata.GetTableOrView(tableName); }
/// <summary> /// Inserts the batch of records as one operation. /// </summary> /// <param name="tableName">Name of the table.</param> /// <param name="tableTypeName">Name of the table type.</param> /// <param name="dataReader">The data reader.</param> /// <param name="options">The options.</param> /// <returns>MultipleRowDbCommandBuilder<SqlCommand, SqlParameter>.</returns> public MultipleRowDbCommandBuilder <SqlCommand, SqlParameter> InsertBatch(SqlServerObjectName tableName, DbDataReader dataReader, SqlServerObjectName tableTypeName, InsertOptions options = InsertOptions.None) { return(new SqlServerInsertBatchTable(this, tableName, dataReader, tableTypeName, options)); }
/// <summary> /// Initializes a new instance of the <see cref="OleDbSqlServerUpdateObject{TArgument}" /> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="tableName">Name of the table.</param> /// <param name="argumentValue">The argument value.</param> /// <param name="options">The options.</param> public OleDbSqlServerUpdateObject(OleDbSqlServerDataSourceBase dataSource, SqlServerObjectName tableName, TArgument argumentValue, UpdateOptions options) : base(dataSource, tableName, argumentValue) { m_Options = options; }
/// <summary> /// Initializes a new instance of the <see cref="OleDbSqlServerTableFunction" /> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="tableFunctionName">Name of the table function.</param> /// <param name="functionArgumentValue">The function argument.</param> public OleDbSqlServerTableFunction(OleDbSqlServerDataSourceBase dataSource, SqlServerObjectName tableFunctionName, object functionArgumentValue) : base(dataSource) { m_Table = dataSource.DatabaseMetadata.GetTableFunction(tableFunctionName); m_FunctionArgumentValue = functionArgumentValue; }
/// <summary> /// Initializes a new instance of the <see cref="SqlServerTableFunction" /> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="scalarFunctionName">Name of the scalar function.</param> /// <param name="functionArgumentValue">The function argument.</param> public SqlServerScalarFunction(SqlServerDataSourceBase dataSource, SqlServerObjectName scalarFunctionName, object functionArgumentValue) : base(dataSource) { m_Function = dataSource.DatabaseMetadata.GetScalarFunction(scalarFunctionName); m_FunctionArgumentValue = functionArgumentValue; }
/// <summary> /// Initializes a new instance of the <see cref="OleDbSqlServerObjectCommand{TArgument}" /> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="tableName">Name of the table.</param> /// <param name="argumentValue">The argument value.</param> protected OleDbSqlServerObjectCommand(OleDbSqlServerDataSourceBase dataSource, SqlServerObjectName tableName, TArgument argumentValue) : base(dataSource, argumentValue) { Table = DataSource.DatabaseMetadata.GetTableOrView(tableName); }
/// <summary> /// Initializes a new instance of the <see cref="SqlServerDeleteMany"/> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="tableName">Name of the table.</param> /// <param name="filterValue">The filter value.</param> /// <param name="filterOptions">The options.</param> public SqlServerDeleteMany(SqlServerDataSourceBase dataSource, SqlServerObjectName tableName, object filterValue, FilterOptions filterOptions) : base(dataSource) { m_Table = dataSource.DatabaseMetadata.GetTableOrView(tableName); m_FilterValue = filterValue; m_FilterOptions = filterOptions; }
/// <summary> /// Initializes a new instance of the <see cref="SqlServerDeleteMany"/> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="tableName">Name of the table.</param> /// <param name="whereClause">The where clause.</param> /// <param name="argumentValue">The argument value.</param> public SqlServerDeleteMany(SqlServerDataSourceBase dataSource, SqlServerObjectName tableName, string whereClause, object argumentValue) : base(dataSource) { m_Table = dataSource.DatabaseMetadata.GetTableOrView(tableName); m_WhereClause = whereClause; m_ArgumentValue = argumentValue; }
/// <summary> /// Inserts the batch of records as one operation.. /// </summary> /// <typeparam name="TObject">The type of the object.</typeparam> /// <param name="tableTypeName">Name of the table type.</param> /// <param name="objects">The objects.</param> /// <param name="options">The options.</param> /// <returns> /// MultipleRowDbCommandBuilder<SqlCommand, SqlParameter>. /// </returns> public MultipleRowDbCommandBuilder <SqlCommand, SqlParameter> InsertBatch <TObject>(IEnumerable <TObject> objects, SqlServerObjectName tableTypeName, InsertOptions options = InsertOptions.None) where TObject : class { return(InsertBatch(DatabaseMetadata.GetTableOrViewFromClass <TObject>().Name, objects, tableTypeName, options)); }
public SqlServerInsertBulk InsertBulk <TObject>(SqlServerObjectName tableName, IEnumerable <TObject> objects, SqlBulkCopyOptions options) where TObject : class { return(InsertBulk <TObject>(tableName, objects).WithOptions(options)); }
public SqlServerInsertBulk InsertBulk(SqlServerObjectName tableName, DataTable dataTable, SqlBulkCopyOptions options) { return(InsertBulk(tableName, dataTable).WithOptions(options)); }
/// <summary> /// Initializes a new instance of the <see cref="SqlServerDeleteObject{TArgument}"/> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="tableName">Name of the table.</param> /// <param name="argumentValue">The argument value.</param> /// <param name="options">The options.</param> public SqlServerDeleteObject(SqlServerDataSourceBase dataSource, SqlServerObjectName tableName, TArgument argumentValue, DeleteOptions options) : base(dataSource, tableName, argumentValue) { m_Options = options; }
public MultipleRowDbCommandBuilder <SqlCommand, SqlParameter> InsertBatch <TObject>(SqlServerObjectName tableName, IEnumerable <TObject> objects, SqlServerObjectName tableTypeName, InsertOptions options = InsertOptions.None) { var tableType = DatabaseMetadata.GetUserDefinedTableType(tableTypeName); return(new SqlServerInsertBatchTable(this, tableName, new ObjectDataReader <TObject>(tableType, objects), tableTypeName, options)); }
/// <summary> /// Initializes a new instance of the <see cref="OleDbSqlServerDeleteMany" /> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="tableName">Name of the table.</param> /// <param name="whereClause">The where clause.</param> /// <param name="parameters">The parameters.</param> public OleDbSqlServerDeleteMany(OleDbSqlServerDataSourceBase dataSource, SqlServerObjectName tableName, string whereClause, IEnumerable <OleDbParameter> parameters) : base(dataSource) { m_Table = dataSource.DatabaseMetadata.GetTableOrView(tableName); m_WhereClause = whereClause; m_Parameters = parameters; }