/// <summary>
        /// Deletes all the records in the table or a range of records if a conditional clause was set up in the statement options.
        /// </summary>
        /// <typeparam name="TEntity">Entity Type</typeparam>
        /// <param name="connection">Database connection.</param>
        /// <param name="statementOptions">Optional statement options (usage: statement => statement.SetTimeout().AttachToTransaction()...)</param>
        /// <returns>The number of records deleted.</returns>
        public static Task <int> BulkDeleteAsync <TEntity>(
            this IDbConnection connection,
            Action <IConditionalBulkSqlStatementOptionsBuilder <TEntity> > statementOptions = null)
        {
            var options = new ConditionalBulkSqlStatementOptionsBuilder <TEntity>();

            statementOptions?.Invoke(options);
            return(options.SqlStatementsFactoryChain().BulkDeleteAsync(connection, options));
        }
        /// <summary>
        /// Updates a number of records in the database.
        /// </summary>
        /// <param name="connection">Database connection.</param>
        /// <param name="updateData">
        /// The data used to update the records.
        /// The primary keys will be ignored.
        /// For partial updates use an entity mapping override.
        /// </param>
        /// <param name="statementOptions">Optional statement options (usage: statement => statement.SetTimeout().AttachToTransaction()...)</param>
        /// <returns>The number of records updated.</returns>
        public static int BulkUpdate <TEntity>(
            this IDbConnection connection,
            TEntity updateData,
            Action <IConditionalBulkSqlStatementOptionsBuilder <TEntity> > statementOptions = null)
        {
            var options = new ConditionalBulkSqlStatementOptionsBuilder <TEntity>();

            statementOptions?.Invoke(options);
            return(options.SqlStatementsFactoryChain().BulkUpdate(connection, updateData, options));
        }
示例#3
0
        /// <summary>
        /// Deletes all the records in the table or a range of records if a conditional clause was set up in the statement options.
        /// </summary>
        /// <typeparam name="TEntity">Entity Type</typeparam>
        /// <param name="connection">Database connection.</param>
        /// <param name="statementOptions">Optional statement options (usage: statement => statement.SetTimeout().AttachToTransaction()...)</param>
        /// <returns>The number of records deleted.</returns>
        public static Task <int> BulkDeleteAsync <TEntity>(
            this IDbConnection connection,
            Action <IConditionalBulkSqlStatementOptionsBuilder <TEntity> > statementOptions = null)
        {
            var options = new ConditionalBulkSqlStatementOptionsBuilder <TEntity>();

            statementOptions?.Invoke(options);
            return(OrmConfiguration
                   .GetSqlStatements <TEntity>(options.EntityMappingOverride)
                   .BulkDeleteAsync(connection, options));
        }
示例#4
0
        /// <summary>
        /// Updates a number of records in the database.
        /// </summary>
        /// <param name="connection">Database connection.</param>
        /// <param name="updateData">
        /// The data used to update the records.
        /// The primary keys will be ignored.
        /// For partial updates use an entity mapping override.
        /// </param>
        /// <param name="statementOptions">Optional statement options (usage: statement => statement.SetTimeout().AttachToTransaction()...)</param>
        /// <returns>The number of records updated.</returns>
        public static int BulkUpdate <TEntity>(
            this IDbConnection connection,
            TEntity updateData,
            Action <IConditionalBulkSqlStatementOptionsBuilder <TEntity> > statementOptions = null)
        {
            var options = new ConditionalBulkSqlStatementOptionsBuilder <TEntity>();

            statementOptions?.Invoke(options);
            return(OrmConfiguration.GetSqlStatements <TEntity>(options.EntityMappingOverride)
                   .BulkUpdate(connection, updateData, options));
        }