public async Task BulkCopyLinqTypesProviderSpecificAsync([IncludeDataSources(TestProvName.AllInformix)] string context) { using (var db = new DataConnection(context)) { try { await db.BulkCopyAsync( new BulkCopyOptions { BulkCopyType = BulkCopyType.ProviderSpecific, RowsCopiedCallback = copied => Debug.WriteLine(copied.RowsCopied) }, Enumerable.Range(0, 10).Select(n => new DataTypes { ID = 4000 + n, MoneyValue = 1000m + n, DateTimeValue = new DateTime(2001, 1, 11, 1, 11, 21, 100), DateTimeValue2 = new DateTime(2001, 1, 10, 1, 11, 21, 100), BoolValue = true, GuidValue = Guid.NewGuid(), BinaryValue = new byte[] { (byte)n }, SmallIntValue = (short)n, IntValue = n, BigIntValue = n, StringValue = n.ToString(), } )); } finally { await db.GetTable <DataTypes>().DeleteAsync(p => p.ID >= 4000); } } }
public override async Task InsertAsync() { if (Histories.Count > 0) { await DataConnection.BulkCopyAsync(GetBulkCopyOptions(), Histories); } }
public async Task BulkCopyLinqTypesAsync([IncludeDataSources(CurrentProvider)] string context) { foreach (var bulkCopyType in new[] { BulkCopyType.MultipleRows, BulkCopyType.ProviderSpecific }) { using (var db = new DataConnection(context)) { try { await db.BulkCopyAsync( new BulkCopyOptions { BulkCopyType = bulkCopyType }, Enumerable.Range(0, 10).Select(n => new LinqDataTypes { ID = 4000 + n, MoneyValue = 1000m + n, DateTimeValue = new DateTime(2001, 1, 11, 1, 11, 21, 100), BoolValue = true, GuidValue = Guid.NewGuid(), SmallIntValue = (short)n } )); } finally { await db.GetTable <LinqDataTypes>().DeleteAsync(p => p.ID >= 4000); } } } }
public virtual async Task <long> InsertAsync(IEnumerable <TEntity> entities) { if (entities == null) { throw new ArgumentNullException(nameof(entities)); } var result = 0L; using (var transaction = new TransactionScope()) { var status = await _dataConnection.BulkCopyAsync(new BulkCopyOptions(), entities); result = status.RowsCopied; transaction.Complete(); } return(result); }
async Task BulkCopyAllTypesAsync(string context, BulkCopyType bulkCopyType) { using (var db = new DataConnection(context)) { db.CommandTimeout = 60; await db.GetTable <AllType>().DeleteAsync(p => p.ID >= _allTypeses[0].ID); var keepIdentity = bulkCopyType == BulkCopyType.ProviderSpecific && ((InformixDataProvider)db.DataProvider).Adapter.IsIDSProvider; try { await db.BulkCopyAsync( new BulkCopyOptions { BulkCopyType = bulkCopyType, RowsCopiedCallback = copied => Debug.WriteLine(copied.RowsCopied), KeepIdentity = keepIdentity }, _allTypeses); var ids = _allTypeses.Select(at => at.ID).ToArray(); var list = await db.GetTable <AllType>().Where(t => ids.Contains(t.ID)).OrderBy(t => t.ID).ToListAsync(); Assert.That(list.Count, Is.EqualTo(_allTypeses.Length)); for (var i = 0; i < list.Count; i++) { CompareObject(db.MappingSchema, list[i], _allTypeses[i]); } } finally { await db.GetTable <AllType>().DeleteAsync(p => p.ID >= _allTypeses[0].ID); } } }