Exemple #1
0
        /// <summary>
        /// Saves a batch of objects. Sets the <see cref="ITransactionScope.AutoCommit"/> to <see langword="true"/>
        /// before executing the save batch operation; then restores it back to its original value.
        /// </summary>
        public static int SaveBatch(this ITransactionScope transactionScope, string table, IEnumerable <object> batch, int chunkSize = 0, IEnumerable <string> whitelist = null, IEnumerable <string> blacklist = null)
        {
            var autoCommit = transactionScope.AutoCommit;

            transactionScope.AutoCommit = true;
            var affectedRows = transactionScope.Do(t => t.SaveBatch(table, batch, chunkSize, whitelist, blacklist));

            transactionScope.AutoCommit = autoCommit;
            return(affectedRows);
        }