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); }
/// <summary> /// Initializes a new instance of the <see cref="SqlServerSqlCall" /> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="sqlStatement">The SQL statement.</param> /// <param name="argumentValue">The argument value.</param> /// <exception cref="ArgumentException">sqlStatement is null or empty.;sqlStatement</exception> public SqlServerSqlCall(SqlServerDataSourceBase dataSource, string sqlStatement, object?argumentValue) : base(dataSource, sqlStatement, argumentValue) { if (string.IsNullOrEmpty(sqlStatement)) { throw new ArgumentException($"{nameof(sqlStatement)} is null or empty.", nameof(sqlStatement)); } }
/// <summary> /// Initializes a new instance of the <see cref="SqlServerDeleteSet" /> 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 SqlServerDeleteSet(SqlServerDataSourceBase dataSource, SqlServerObjectName tableName, string whereClause, IEnumerable <SqlParameter> 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="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="SqlServerSqlCall" /> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="sqlStatement">The SQL statement.</param> /// <param name="argumentValue">The argument value.</param> /// <exception cref="ArgumentException">sqlStatement is null or empty.;sqlStatement</exception> public SqlServerSqlCall(SqlServerDataSourceBase dataSource, string sqlStatement, object argumentValue) : base(dataSource) { if (string.IsNullOrEmpty(sqlStatement)) { throw new ArgumentException("sqlStatement is null or empty.", "sqlStatement"); } m_SqlStatement = sqlStatement; m_ArgumentValue = argumentValue; }
/// <summary> /// Initializes a new instance of the <see cref="SqlServerUpdateMany" /> 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 SqlServerUpdateMany(SqlServerDataSourceBase 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; }
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="SqlServerTableOrView" /> 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 SqlServerTableOrView(SqlServerDataSourceBase 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="SqlServerTableOrView"/> 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 SqlServerTableOrView(SqlServerDataSourceBase 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); }
/// <summary> /// Initializes a new instance of the <see cref="SqlServerUpdateMany" /> 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 SqlServerUpdateMany(SqlServerDataSourceBase 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="SqlServerUpdateMany" /> 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 SqlServerUpdateMany(SqlServerDataSourceBase dataSource, SqlServerObjectName tableName, object?newValues, string whereClause, IEnumerable <SqlParameter> 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); }
/// <summary> /// Initializes a new instance of the <see cref="SqlServerTableFunction" /> 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 SqlServerTableFunction(SqlServerDataSourceBase 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="SqlServerUpdateObject{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 SqlServerUpdateObject(SqlServerDataSourceBase dataSource, SqlServerObjectName tableName, TArgument argumentValue, UpdateOptions options) : base(dataSource, tableName, argumentValue) { m_Options = options; }
/// <summary> /// Initializes a new instance of the <see cref="SqlServerDeleteSet"/> 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 SqlServerDeleteSet(SqlServerDataSourceBase 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="SqlServerObjectCommand{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 SqlServerObjectCommand(SqlServerDataSourceBase 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> /// 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; }