public void TestMicrosoftSqlConnectionBulkMergeForEntitiesWithExtraFields() { // Setup var tables = Helper.CreateWithExtraFieldsBulkOperationIdentityTables(10); using (var repository = new WithExtraFieldsBulkOperationIdentityTableRepository()) { // Setup repository.InsertAll(tables); // Setup Helper.UpdateWithExtraFieldsBulkOperationIdentityTables(tables); // Act var bulkMergeResult = repository.BulkMerge(tables); // Assert Assert.AreEqual(tables.Count, bulkMergeResult); // Act var queryResult = repository.DbRepository.QueryAll <BulkOperationIdentityTable>(); // Assert Assert.AreEqual(tables.Count, queryResult.Count()); tables.AsList().ForEach(t => { Helper.AssertPropertiesEquality(t, queryResult.ElementAt(tables.IndexOf(t))); }); } }
public void TestMicrosoftSqlConnectionBulkMergeForEntitiesWithExtraFieldsWithMappings() { // Setup var tables = Helper.CreateWithExtraFieldsBulkOperationIdentityTables(10); var mappings = new List <BulkInsertMapItem>(); // Add the mappings mappings.Add(new BulkInsertMapItem(nameof(BulkOperationIdentityTable.ColumnBit), nameof(BulkOperationIdentityTable.ColumnBit))); mappings.Add(new BulkInsertMapItem(nameof(BulkOperationIdentityTable.ColumnDateTime), nameof(BulkOperationIdentityTable.ColumnDateTime))); mappings.Add(new BulkInsertMapItem(nameof(BulkOperationIdentityTable.ColumnDateTime2), nameof(BulkOperationIdentityTable.ColumnDateTime2))); mappings.Add(new BulkInsertMapItem(nameof(BulkOperationIdentityTable.ColumnDecimal), nameof(BulkOperationIdentityTable.ColumnDecimal))); mappings.Add(new BulkInsertMapItem(nameof(BulkOperationIdentityTable.ColumnFloat), nameof(BulkOperationIdentityTable.ColumnFloat))); mappings.Add(new BulkInsertMapItem(nameof(BulkOperationIdentityTable.ColumnInt), nameof(BulkOperationIdentityTable.ColumnInt))); mappings.Add(new BulkInsertMapItem(nameof(BulkOperationIdentityTable.ColumnNVarChar), nameof(BulkOperationIdentityTable.ColumnNVarChar))); using (var repository = new WithExtraFieldsBulkOperationIdentityTableRepository()) { // Setup repository.InsertAll(tables); // Setup Helper.UpdateWithExtraFieldsBulkOperationIdentityTables(tables); // Act var bulkMergeResult = repository.BulkMerge(tables); // Assert Assert.AreEqual(tables.Count, bulkMergeResult); // Act var queryResult = repository.DbRepository.QueryAll <BulkOperationIdentityTable>(); // Assert Assert.AreEqual(tables.Count, queryResult.Count()); tables.AsList().ForEach(t => { Helper.AssertPropertiesEquality(t, queryResult.ElementAt(tables.IndexOf(t))); }); } }