/// <summary> /// Initializes a new instance of the <see cref="AccessTableOrView" /> 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> public AccessTableOrView(AccessDataSourceBase dataSource, AccessObjectName tableOrViewName, object filterValue, FilterOptions filterOptions) : base(dataSource) { m_FilterValue = filterValue; m_Table = ((AccessDataSourceBase)DataSource).DatabaseMetadata.GetTableOrView(tableOrViewName); m_FilterOptions = filterOptions; }
/// <summary> /// Initializes a new instance of the <see cref="AccessTableOrView" /> class. /// </summary> /// <param name="dataSource"></param> /// <param name="tableOrViewName"></param> /// <param name="whereClause"></param> /// <param name="argumentValue"></param> public AccessTableOrView(AccessDataSourceBase dataSource, AccessObjectName tableOrViewName, string whereClause, object argumentValue) : base(dataSource) { m_ArgumentValue = argumentValue; m_WhereClause = whereClause; m_Table = ((AccessDataSourceBase)DataSource).DatabaseMetadata.GetTableOrView(tableOrViewName); }
private partial ILink <int?> OnDeleteAll(AccessObjectName tableName) { //Verify the table name actually exists. var table = DatabaseMetadata.GetTableOrView(tableName); return(Sql("DELETE FROM " + table.Name.ToQuotedString() + ";").AsNonQuery()); }
/// <summary> /// Initializes a new instance of the <see cref="AccessDeleteSet" /> 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 AccessDeleteSet(AccessDataSourceBase dataSource, AccessObjectName 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="AccessUpdateSet" /> 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 AccessUpdateSet(AccessDataSourceBase dataSource, AccessObjectName 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="AccessUpdateSet" /> 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 AccessUpdateSet(AccessDataSourceBase dataSource, AccessObjectName 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="AccessDeleteMany" /> 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 AccessDeleteMany(AccessDataSourceBase dataSource, AccessObjectName tableName, string whereClause, IEnumerable <OleDbParameter> 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="AccessUpdateSet" /> 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 AccessUpdateSet(AccessDataSourceBase dataSource, AccessObjectName 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; }
/// <summary> /// Initializes a new instance of the <see cref="AccessDeleteObject{TArgument}"/> class. /// </summary> /// <param name="dataSource">The data source.</param> /// <param name="tableName">The table.</param> /// <param name="argumentValue">The argument value.</param> /// <param name="options">The options.</param> public AccessDeleteObject(AccessDataSourceBase dataSource, AccessObjectName tableName, TArgument argumentValue, DeleteOptions options) : base(dataSource, tableName, argumentValue) { m_Options = options; }
/// <summary> /// Initializes a new instance of the <see cref="AccessDeleteMany"/> 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 AccessDeleteMany(AccessDataSourceBase dataSource, AccessObjectName 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="AccessObjectCommand{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 AccessObjectCommand(AccessDataSourceBase dataSource, AccessObjectName tableName, TArgument argumentValue) : base(dataSource, argumentValue) { Table = ((AccessDataSourceBase)DataSource).DatabaseMetadata.GetTableOrView(tableName); }
/// <summary> /// Initializes a new instance of the <see cref="AccessDeleteSet"/> 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 AccessDeleteSet(AccessDataSourceBase dataSource, AccessObjectName tableName, object filterValue, FilterOptions filterOptions) : base(dataSource, filterValue, filterOptions) { m_Table = dataSource.DatabaseMetadata.GetTableOrView(tableName); }
/// <summary> /// Initializes a new instance of the <see cref="AccessDeleteSet"/> 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 AccessDeleteSet(AccessDataSourceBase dataSource, AccessObjectName tableName, string whereClause, object?argumentValue) : base(dataSource, whereClause, argumentValue) { m_Table = dataSource.DatabaseMetadata.GetTableOrView(tableName); }
MultipleRowDbCommandBuilder <AbstractCommand, AbstractParameter> IUpdateDeleteByKeyHelper <AbstractCommand, AbstractParameter, AbstractObjectName, AbstractDbType> .OnDeleteByKeyList <TKey>(AccessObjectName tableName, IEnumerable <TKey> keys, DeleteOptions options) { var primaryKeys = DatabaseMetadata.GetTableOrView(tableName).PrimaryKeyColumns; if (primaryKeys.Count != 1) { throw new MappingException($"DeleteByKey/DeleteByKeyList operation isn't allowed on {tableName} because it doesn't have a single primary key."); } var keyList = keys.AsList(); var columnMetadata = primaryKeys.Single(); string where; if (keys.Count() > 1) { where = columnMetadata.SqlName + " IN (" + string.Join(", ", keyList.Select((s, i) => "@Param" + i)) + ")"; } else { where = columnMetadata.SqlName + " = @Param0"; } var parameters = new List <OleDbParameter>(); for (var i = 0; i < keyList.Count; i++) { var param = new OleDbParameter("@Param" + i, keyList[i]); if (columnMetadata.DbType.HasValue) { param.OleDbType = columnMetadata.DbType.Value; } parameters.Add(param); } var table = DatabaseMetadata.GetTableOrView(tableName); if (!AuditRules.UseSoftDelete(table)) { return(new AccessDeleteSet(this, tableName, where, parameters, parameters.Count, options)); } UpdateOptions effectiveOptions = UpdateOptions.SoftDelete; if (!options.HasFlag(DeleteOptions.CheckRowsAffected)) { effectiveOptions |= UpdateOptions.IgnoreRowsAffected; } if (options.HasFlag(DeleteOptions.UseKeyAttribute)) { effectiveOptions |= UpdateOptions.UseKeyAttribute; } return(new AccessUpdateSet(this, tableName, null, where, parameters, parameters.Count, effectiveOptions)); }
MultipleRowDbCommandBuilder <AbstractCommand, AbstractParameter> IUpdateDeleteByKeyHelper <AbstractCommand, AbstractParameter, AbstractObjectName, AbstractDbType> .OnUpdateByKeyList <TArgument, TKey>(AccessObjectName tableName, TArgument newValues, IEnumerable <TKey> keys, UpdateOptions options) { var primaryKeys = DatabaseMetadata.GetTableOrView(tableName).PrimaryKeyColumns; if (primaryKeys.Count != 1) { throw new MappingException($"UpdateByKeyList operation isn't allowed on {tableName} because it doesn't have a single primary key."); } var keyList = keys.AsList(); var columnMetadata = primaryKeys.Single(); string where; if (keys.Count() > 1) { where = columnMetadata.SqlName + " IN (" + string.Join(", ", keyList.Select((s, i) => "@Param" + i)) + ")"; } else { where = columnMetadata.SqlName + " = @Param0"; } var parameters = new List <OleDbParameter>(); for (var i = 0; i < keyList.Count; i++) { var param = new OleDbParameter("@Param" + i, keyList[i]); if (columnMetadata.DbType.HasValue) { param.OleDbType = columnMetadata.DbType.Value; } parameters.Add(param); } return(new AccessUpdateSet(this, tableName, newValues, where, parameters, parameters.Count, options)); }