Ejemplo n.º 1
0
        public void Test_MixedCaseEntity_BulkInsert()
        {
            subject = new PostgreSQLCopyHelper <MixedCaseEntity>("sample", "\"MixedCaseEntity\"")
                      .MapInteger("\"Property_One\"", x => x.Property_One)
                      .MapText("\"Property_Two\"", x => x.Property_Two);

            // Try to work with the Bulk Inserter:
            var entity0 = new MixedCaseEntity
            {
                Property_One = 44,
                Property_Two = "hello everyone"
            };

            var entity1 = new MixedCaseEntity
            {
                Property_One = 89,
                Property_Two = "Isn't it nice to write in Camel Case!"
            };

            subject.SaveAll(connection, new[] { entity0, entity1 });

            var result = connection.GetAll("sample", "\"MixedCaseEntity\"");

            // Check if we have the amount of rows:
            Assert.AreEqual(2, result.Count);

            Assert.IsNotNull(result[0][0]);
            Assert.IsNotNull(result[1][0]);

            Assert.AreEqual(entity0.Property_One, (Int32)result[0][0]);
            Assert.AreEqual(entity0.Property_Two, (string)result[0][1]);

            Assert.AreEqual(entity1.Property_One, (Int32)result[1][0]);
            Assert.AreEqual(entity1.Property_Two, (string)result[1][1]);
        }
        public void Test_MixedCaseEntity_BulkInsert()
        {
            subject = new PostgreSQLCopyHelper<MixedCaseEntity>("sample", "\"MixedCaseEntity\"")
                     .MapInteger("\"Property_One\"", x => x.Property_One)
                     .MapText("\"Property_Two\"", x => x.Property_Two);

            // Try to work with the Bulk Inserter:
            var entity0 = new MixedCaseEntity
            {
                Property_One = 44,
                Property_Two = "hello everyone"
            };

            var entity1 = new MixedCaseEntity
            {
                Property_One = 89,
                Property_Two = "Isn't it nice to write in Camel Case!"
            };

            subject.SaveAll(connection, new[] { entity0, entity1 });

            var result = connection.GetAll("sample", "\"MixedCaseEntity\"");

            // Check if we have the amount of rows:
            Assert.AreEqual(2, result.Count);

            Assert.IsNotNull(result[0][0]);
            Assert.IsNotNull(result[1][0]);

            Assert.AreEqual(entity0.Property_One, (Int32)result[0][0]);
            Assert.AreEqual(entity0.Property_Two, (string)result[0][1]);

            Assert.AreEqual(entity1.Property_One, (Int32)result[1][0]);
            Assert.AreEqual(entity1.Property_Two, (string)result[1][1]);
        }