public void SetupPeople() { var faker = PersonFaker(); var jacob = faker.Generate(); jacob.FirstName = "Jacob"; var bob = faker.Generate(); bob.FirstName = "Bob"; var jacobWife = faker.Generate(); jacobWife.SpouseId = jacob.Id; jacob.SpouseId = jacobWife.Id; Assert.Empty(_dbConnection.People); _dbConnection.Insert(jacob); _dbConnection.Insert(jacobWife); _dbConnection.Insert(bob); _dbConnection.BulkCopy(faker.Generate(5)); _dbConnection.Insert(jacob.Staff); _dbConnection.Insert(bob.Staff); var jacobGroup = AutoFaker.Generate <OrgGroup>(); jacobGroup.Id = jacob.Staff.OrgGroupId ?? Guid.Empty; jacobGroup.Supervisor = bob.Id; jacobGroup.ApproverIsSupervisor = true; _dbConnection.Insert(jacobGroup); var jacobMissionOrg = AutoFaker.Generate <MissionOrg>(); jacobMissionOrg.Id = jacob.Staff.MissionOrgId ?? Guid.Empty; _dbConnection.Insert(jacobMissionOrg); }
public void TestBulkLoad() { try { _connection.ExecuteSql("CREATE TABLE InsightTestData (ID int, Dec Decimal, TestData xml, Text varchar(256))"); for (int i = 0; i < 3; i++) { var text = "test with spaces and \" quotes in it"; // build test data PostgresBulkData[] array = new PostgresBulkData[i]; for (int j = 0; j < i; j++) { array[j] = new PostgresBulkData() { ID = j, Dec = j, TestData = new TestData(), Text = text } } ; // bulk load the data _connection.BulkCopy("InsightTestData", array, configure: bulkCopy => bulkCopy.BatchSize = 10); // run the query var items = _connection.QuerySql <PostgresBulkData>("SELECT * FROM InsightTestData"); Assert.IsNotNull(items); Assert.AreEqual(i, items.Count); for (int j = 0; j < i; j++) { Assert.AreEqual(j, items[j].ID); Assert.AreEqual(j, items[j].Dec); Assert.AreEqual(text, items[j].Text); } _connection.ExecuteSql("DELETE FROM InsightTestData"); } } finally { try { _connection.ExecuteSql("DROP TABLE InsightTestData"); } catch { } } }
public void TestBulkLoad() { try { // NOTE: I have not been able to get the xmltype to bulk copy. It throws "unsupported column datatype". // Insight will store the value of the object as a string in the bulk copy //_connection.ExecuteSql("CREATE TABLE InsightTestData (ID int, Dec Decimal, TestData xmltype)"); _connection.ExecuteSql("CREATE TABLE InsightTestData (ID int, Dec Decimal)"); Assert.Throws <NotImplementedException>(() => _connection.BulkCopy("InsightTestData", new List <int>())); } finally { try { _connection.ExecuteSql("DROP TABLE InsightTestData"); } catch { } } }
public void TestBulkLoad() { try { // NOTE: I have not been able to get the xmltype to bulk copy. It throws "unsupported column datatype". // Insight will store the value of the object as a string in the bulk copy //_connection.ExecuteSql("CREATE TABLE InsightTestData (ID int, Dec Decimal, TestData xmltype)"); _connection.ExecuteSql("CREATE TABLE InsightTestData (ID int, Dec Decimal)"); for (int i = 0; i < 3; i++) { // build test data ParentTestData[] array = new ParentTestData[i]; for (int j = 0; j < i; j++) { array[j] = new ParentTestData() { ID = j, Dec = j, TestData = new TestData() } } ; // bulk load the data _connection.BulkCopy("InsightTestData", array, configure: bulkCopy => bulkCopy.BatchSize = 10); // run the query var items = _connection.QuerySql <ParentTestData>("SELECT * FROM InsightTestData"); Assert.IsNotNull(items); Assert.AreEqual(i, items.Count); for (int j = 0; j < i; j++) { Assert.AreEqual(j, items[j].ID); Assert.AreEqual(j, items[j].Dec); } _connection.ExecuteSql("DELETE FROM InsightTestData"); } } finally { try { _connection.ExecuteSql("DROP TABLE InsightTestData"); } catch { } } }
public void TestBulkLoad() { try { _connection.ExecuteSql("CREATE TABLE InsightTestData (ID int, Dec Decimal)"); for (int i = 0; i < 3; i++) { // build test data ParentTestData[] array = new ParentTestData[i]; for (int j = 0; j < i; j++) { array[j] = new ParentTestData() { ID = j, Dec = j, TestData = new TestData() } } ; // bulk load the data _connection.BulkCopy("InsightTestData", array, configure: bulkCopy => bulkCopy.BatchSize = 10); // run the query var items = _connection.QuerySql <ParentTestData>("SELECT * FROM InsightTestData"); Assert.IsNotNull(items); Assert.AreEqual(i, items.Count); for (int j = 0; j < i; j++) { Assert.AreEqual(j, items[j].ID); Assert.AreEqual(j, items[j].Dec); } _connection.ExecuteSql("DELETE FROM InsightTestData"); } } finally { try { _connection.ExecuteSql("DROP TABLE InsightTestData"); } catch { } } }
public void InsertAll(IEnumerable <StaffTraining> staffTraining) { _connection.BulkCopy(staffTraining); }