public async Task InsertSingleAsync() { var item = new CustomColumnName { Name = Guid.NewGuid().ToString(), LongCol = 1000, IntCol = 1 }; using (var connection = this.GetConnection()) { connection.Open(); var inserted = (await connection.BulkInsertAndSelectAsync(new List <CustomColumnName> { item })).First(); IsValidInsert(inserted, item); } }
public void InsertSingleTransaction() { var item = new CustomColumnName { Name = Guid.NewGuid().ToString(), LongCol = 1000, IntCol = 1 }; using (var connection = this.GetConnection()) { connection.Open(); using (var transaction = connection.BeginTransaction()) { var inserted = connection.BulkInsertAndSelect(new List <CustomColumnName> { item }, transaction).First(); IsValidInsert(inserted, item); } } }
private static void IsValidInsert(CustomColumnName inserted, CustomColumnName toBeInserted) { inserted.IdKey.Should().BePositive(); inserted.Name.Should().Be(toBeInserted.Name); }