/// <summary> /// Insert new records into table using BulkCopy. /// </summary> /// <param name="items">Records to insert into table.</param> /// <param name="options">Optional BulkCopy options.</param> /// <returns>Number of records, inserted into table.</returns> public long Copy(IEnumerable <T> items, BulkCopyOptions options = null) { var count = options != null? _table.BulkCopy(options, items) : _table.BulkCopy(items); TotalCopied += count.RowsCopied; return(count.RowsCopied); }
public static BulkCopyRowsCopied ProviderSpecificBulkCopy <T>(this ITable <T> table, IEnumerable <T> source, int bulkCopyTimeout = 0, bool keepIdentity = false, int notifyAfter = 0, Action <BulkCopyRowsCopied> rowsCopiedCallback = null) => table.BulkCopy(new BulkCopyOptions { BulkCopyType = BulkCopyType.ProviderSpecific, BulkCopyTimeout = bulkCopyTimeout, KeepIdentity = keepIdentity, NotifyAfter = notifyAfter, RowsCopiedCallback = rowsCopiedCallback }, source);
private void ExecuteBulkReplace(IEnumerable <object> sourceDtos) { var replaceDataObjectCommand = new ReplaceDataObjectCommand(DataObjectType, sourceDtos); var findSpecification = _dataObjectAccessor.GetFindSpecification(replaceDataObjectCommand); var predicate = (Expression <Func <TDataObject, bool> >)PredicateInfo.GetValue(findSpecification); _table.Delete <TDataObject>(predicate); var dataObjects = _dataObjectAccessor.GetDataObjects(replaceDataObjectCommand); try { _table.BulkCopy <TDataObject>(_bulkCopyOptions, dataObjects); } catch (Exception ex) { throw new DataException($"Error occurred while bulk replacing data for data object of type {DataObjectType.Name} using {_dataObjectAccessor.GetType().Name}{Environment.NewLine}", ex); } }
public static BulkCopyRowsCopied MultipleRowsCopy <T>(ITable <T> table, IEnumerable <T> source, int maxBatchSize = 1000, Action <BulkCopyRowsCopied> rowsCopiedCallback = null) => table.BulkCopy(new BulkCopyOptions { BulkCopyType = BulkCopyType.MultipleRows, MaxBatchSize = maxBatchSize, RowsCopiedCallback = rowsCopiedCallback }, source);