Пример #1
0
        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);
            }
        }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
 private static void IsValidInsert(CustomColumnName inserted, CustomColumnName toBeInserted)
 {
     inserted.IdKey.Should().BePositive();
     inserted.Name.Should().Be(toBeInserted.Name);
 }