Exemple #1
0
        public void Z_Test_0001()
        {
            // Title2: MapSingle

            Helper.CleanDatabase();

            var singleBefore = new EntitySimple_Mapper {
                Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40
            };
            var single = new EntitySimple_Mapper {
                Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40
            };

            using (var cn = Helper.GetConnection())
            {
                cn.Open();

                // PreTest

                // Action
                DapperPlusManager.Entity <EntitySimple_Mapper>("47759b26-fbb7-42f3-94af-95166e61a431").Map(x => x.Single1); cn.BulkInsert("47759b26-fbb7-42f3-94af-95166e61a431", single);
            }

            // GET count
            int single1 = 0;
            int single2 = 0;
            int many1   = 0;
            int many2   = 0;
            int many3   = 0;
            int many4   = 0;

            int single1_Destination = 0;
            int single2_Destination = 0;
            int many1_Destination   = 0;
            int many2_Destination   = 0;
            int many3_Destination   = 0;
            int many4_Destination   = 0;

            using (var connection = Helper.GetConnection())
            {
                connection.Open();

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = @"
				SELECT TOP 1
						[Single1] ,
						[Single2] ,
						[Many1] ,
						[Many2] ,
						[Many3] ,
						[Many4] ,
						[Single1_Destination] ,
						[Single2_Destination] ,
						[Many1_Destination] ,
						[Many2_Destination] ,
						[Many3_Destination] ,
						[Many4_Destination] "                         +
                                          "FROM    [Z.Dapper.Plus].[dbo].[EntitySimple_Mapper]";

                    using (var reader = command.ExecuteReader())
                    {
                        reader.Read();
                        single1 = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                        single2 = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                        many1   = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
                        many2   = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
                        many3   = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
                        many4   = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);

                        single1_Destination = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
                        single2_Destination = reader.IsDBNull(7) ? 0 : reader.GetInt32(7);
                        many1_Destination   = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
                        many2_Destination   = reader.IsDBNull(9) ? 0 : reader.GetInt32(9);
                        many3_Destination   = reader.IsDBNull(10) ? 0 : reader.GetInt32(10);
                        many4_Destination   = reader.IsDBNull(11) ? 0 : reader.GetInt32(11);
                    }
                }
            }

            // Test
            Assert.AreEqual(singleBefore.Single1, single1);
            Assert.AreEqual(0, single2);
            Assert.AreEqual(0, many1);
            Assert.AreEqual(0, many2);
            Assert.AreEqual(0, many3);
            Assert.AreEqual(0, many4);
            Assert.AreEqual(0, single1_Destination);
            Assert.AreEqual(0, single2_Destination);
            Assert.AreEqual(0, many1_Destination);
            Assert.AreEqual(0, many2_Destination);
            Assert.AreEqual(0, many3_Destination);
            Assert.AreEqual(0, many4_Destination);
            Assert.AreEqual(singleBefore.Single1, single.Single1);
            Assert.AreEqual(singleBefore.Single2, single.Single2);
            Assert.AreEqual(singleBefore.Many1, single.Many1);
            Assert.AreEqual(singleBefore.Many2, single.Many2);
            Assert.AreEqual(singleBefore.Many3, single.Many3);
            Assert.AreEqual(singleBefore.Many4, single.Many4);
        }
Exemple #2
0
        public void Z_Test_0066()
        {
            // Title2: OutputManyDestination_OutputManyDestination

            Helper.CleanDatabase();

            var singleBefore = new EntitySimple_Mapper { Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40};
            var single = new EntitySimple_Mapper { Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40};

            using (var cn = Helper.GetConnection())
            {
                cn.Open();

                // PreTest

                // Action
                    DapperPlusManager.Entity<EntitySimple_Mapper>("5e94448a-4977-46fe-91f0-5174268b03c5").Table("EntitySimple_TriggerOutput").Output(x => new {Many1_Destination = x.Many1, Many2_Destination = x.Many2}).Output(x => new { Many3_Destination = x.Many3, Many4_Destination = x.Many4});cn.BulkInsert("5e94448a-4977-46fe-91f0-5174268b03c5", single);
            }

            // GET count
            int single1 = 0;
            int single2 = 0;
            int many1 = 0;
            int many2 = 0;
            int many3 = 0;
            int many4 = 0;

            int single1_Destination = 0;
            int single2_Destination = 0;
            int many1_Destination = 0;
            int many2_Destination = 0;
            int many3_Destination = 0;
            int many4_Destination = 0;

            using (var connection = Helper.GetConnection())
            {
                connection.Open();

                using (var command = connection.CreateCommand())
                {

                command.CommandText = @"
                SELECT TOP 1
                        [Single1] ,
                        [Single2] ,
                        [Many1] ,
                        [Many2] ,
                        [Many3] ,
                        [Many4] ,
                        [Single1_Destination] ,
                        [Single2_Destination] ,
                        [Many1_Destination] ,
                        [Many2_Destination] ,
                        [Many3_Destination] ,
                        [Many4_Destination] " +
                    "FROM    [Z.Dapper.Plus].[dbo].[EntitySimple_TriggerOutput]";

                    using (var reader = command.ExecuteReader())
                    {
                        reader.Read();
                        single1 = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                        single2 = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                        many1 = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
                        many2 = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
                        many3 = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
                        many4 = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);

                        single1_Destination = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
                        single2_Destination = reader.IsDBNull(7) ? 0 : reader.GetInt32(7);
                        many1_Destination = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
                        many2_Destination = reader.IsDBNull(9) ? 0 : reader.GetInt32(9);
                        many3_Destination = reader.IsDBNull(10) ? 0 : reader.GetInt32(10);
                        many4_Destination = reader.IsDBNull(11) ? 0 : reader.GetInt32(11);
                    }
                }
            }

            // Test
            Assert.AreEqual(singleBefore.Single1, single.Single1);
            Assert.AreEqual(singleBefore.Single2, single.Single2);
            Assert.AreEqual(-singleBefore.Many1*100, single.Many1);
            Assert.AreEqual(-singleBefore.Many2*100, single.Many2);
            Assert.AreEqual(-singleBefore.Many3*100, single.Many3);
            Assert.AreEqual(-singleBefore.Many4*100, single.Many4);
        }
Exemple #3
0
        public void Z_Test_0047()
        {
            // Title2: OutputSingle

            Helper.CleanDatabase();

            var singleBefore = new EntitySimple_Mapper { Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40};
            var single = new EntitySimple_Mapper { Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40};

            using (var cn = Helper.GetConnection())
            {
                cn.Open();

                // PreTest

                // Action
                    DapperPlusManager.Entity<EntitySimple_Mapper>("b82600c4-1d20-40a7-8cf1-a57ee9d1b56f").Table("EntitySimple_TriggerOutput").Output(x => x.Single1);cn.BulkInsert("b82600c4-1d20-40a7-8cf1-a57ee9d1b56f", single);
            }

            // GET count
            int single1 = 0;
            int single2 = 0;
            int many1 = 0;
            int many2 = 0;
            int many3 = 0;
            int many4 = 0;

            int single1_Destination = 0;
            int single2_Destination = 0;
            int many1_Destination = 0;
            int many2_Destination = 0;
            int many3_Destination = 0;
            int many4_Destination = 0;

            using (var connection = Helper.GetConnection())
            {
                connection.Open();

                using (var command = connection.CreateCommand())
                {

                command.CommandText = @"
                SELECT TOP 1
                        [Single1] ,
                        [Single2] ,
                        [Many1] ,
                        [Many2] ,
                        [Many3] ,
                        [Many4] ,
                        [Single1_Destination] ,
                        [Single2_Destination] ,
                        [Many1_Destination] ,
                        [Many2_Destination] ,
                        [Many3_Destination] ,
                        [Many4_Destination] " +
                    "FROM    [Z.Dapper.Plus].[dbo].[EntitySimple_TriggerOutput]";

                    using (var reader = command.ExecuteReader())
                    {
                        reader.Read();
                        single1 = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                        single2 = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                        many1 = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
                        many2 = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
                        many3 = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
                        many4 = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);

                        single1_Destination = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
                        single2_Destination = reader.IsDBNull(7) ? 0 : reader.GetInt32(7);
                        many1_Destination = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
                        many2_Destination = reader.IsDBNull(9) ? 0 : reader.GetInt32(9);
                        many3_Destination = reader.IsDBNull(10) ? 0 : reader.GetInt32(10);
                        many4_Destination = reader.IsDBNull(11) ? 0 : reader.GetInt32(11);
                    }
                }
            }

            // Test
            Assert.AreEqual(-singleBefore.Single1, single.Single1);
            Assert.AreEqual(singleBefore.Single2, single.Single2);
            Assert.AreEqual(singleBefore.Many1, single.Many1);
            Assert.AreEqual(singleBefore.Many2, single.Many2);
            Assert.AreEqual(singleBefore.Many3, single.Many3);
            Assert.AreEqual(singleBefore.Many4, single.Many4);
        }
Exemple #4
0
        public void Z_Test_0045()
        {
            // Title2: IdentityManyDestination_IdentityMany

            Helper.CleanDatabase();

            var singleBefore = new EntitySimple_Mapper {
                Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40
            };
            var single = new EntitySimple_Mapper {
                Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40
            };

            using (var cn = Helper.GetConnection())
            {
                cn.Open();

                // PreTest

                // Action
                DapperPlusManager.Entity <EntitySimple_Mapper>("6c3d65ce-bcbc-4f75-b542-2a8a9c594eaf").Table("EntitySimple_TriggerOutput").Identity(x => new { Many1_Destination = x.Many1, Many2_Destination = x.Many2 }).Identity(x => new { x.Many3, x.Many4 }); cn.BulkInsert("6c3d65ce-bcbc-4f75-b542-2a8a9c594eaf", single);
            }

            // GET count
            int single1 = 0;
            int single2 = 0;
            int many1   = 0;
            int many2   = 0;
            int many3   = 0;
            int many4   = 0;

            int single1_Destination = 0;
            int single2_Destination = 0;
            int many1_Destination   = 0;
            int many2_Destination   = 0;
            int many3_Destination   = 0;
            int many4_Destination   = 0;

            using (var connection = Helper.GetConnection())
            {
                connection.Open();

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = @"
				SELECT TOP 1
						[Single1] ,
						[Single2] ,
						[Many1] ,
						[Many2] ,
						[Many3] ,
						[Many4] ,
						[Single1_Destination] ,
						[Single2_Destination] ,
						[Many1_Destination] ,
						[Many2_Destination] ,
						[Many3_Destination] ,
						[Many4_Destination] "                         +
                                          "FROM    [Z.Dapper.Plus].[dbo].[EntitySimple_TriggerOutput]";

                    using (var reader = command.ExecuteReader())
                    {
                        reader.Read();
                        single1 = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                        single2 = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                        many1   = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
                        many2   = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
                        many3   = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
                        many4   = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);

                        single1_Destination = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
                        single2_Destination = reader.IsDBNull(7) ? 0 : reader.GetInt32(7);
                        many1_Destination   = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
                        many2_Destination   = reader.IsDBNull(9) ? 0 : reader.GetInt32(9);
                        many3_Destination   = reader.IsDBNull(10) ? 0 : reader.GetInt32(10);
                        many4_Destination   = reader.IsDBNull(11) ? 0 : reader.GetInt32(11);
                    }
                }
            }

            // Test
            Assert.AreEqual(singleBefore.Single1, single.Single1);
            Assert.AreEqual(singleBefore.Single2, single.Single2);
            Assert.AreEqual(-singleBefore.Many1 * 100, single.Many1);
            Assert.AreEqual(-singleBefore.Many2 * 100, single.Many2);
            Assert.AreEqual(-singleBefore.Many3, single.Many3);
            Assert.AreEqual(-singleBefore.Many4, single.Many4);
        }
Exemple #5
0
        public void Z_Test_0018()
        {
            // Title2: MapManyDestination_MapSingleDestination

            Helper.CleanDatabase();

            var singleBefore = new EntitySimple_Mapper { Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40};
            var single = new EntitySimple_Mapper { Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40};

            using (var cn = Helper.GetConnection())
            {
                cn.Open();

                // PreTest

                // Action
                    DapperPlusManager.Entity<EntitySimple_Mapper>("fc9030b9-c27a-4b76-b002-d39b7cb6b3fc").Map(x => new {Many1_Destination = x.Many1, Many2_Destination = x.Many2}).Map(x => x.Single2, "Single2_Destination");cn.BulkInsert("fc9030b9-c27a-4b76-b002-d39b7cb6b3fc", single);
            }

            // GET count
            int single1 = 0;
            int single2 = 0;
            int many1 = 0;
            int many2 = 0;
            int many3 = 0;
            int many4 = 0;

            int single1_Destination = 0;
            int single2_Destination = 0;
            int many1_Destination = 0;
            int many2_Destination = 0;
            int many3_Destination = 0;
            int many4_Destination = 0;

            using (var connection = Helper.GetConnection())
            {
                connection.Open();

                using (var command = connection.CreateCommand())
                {

                command.CommandText = @"
                SELECT TOP 1
                        [Single1] ,
                        [Single2] ,
                        [Many1] ,
                        [Many2] ,
                        [Many3] ,
                        [Many4] ,
                        [Single1_Destination] ,
                        [Single2_Destination] ,
                        [Many1_Destination] ,
                        [Many2_Destination] ,
                        [Many3_Destination] ,
                        [Many4_Destination] " +
                    "FROM    [Z.Dapper.Plus].[dbo].[EntitySimple_Mapper]";

                    using (var reader = command.ExecuteReader())
                    {
                        reader.Read();
                        single1 = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                        single2 = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                        many1 = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
                        many2 = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
                        many3 = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
                        many4 = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);

                        single1_Destination = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
                        single2_Destination = reader.IsDBNull(7) ? 0 : reader.GetInt32(7);
                        many1_Destination = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
                        many2_Destination = reader.IsDBNull(9) ? 0 : reader.GetInt32(9);
                        many3_Destination = reader.IsDBNull(10) ? 0 : reader.GetInt32(10);
                        many4_Destination = reader.IsDBNull(11) ? 0 : reader.GetInt32(11);
                    }
                }
            }

            // Test
            Assert.AreEqual(0, single1);
            Assert.AreEqual(0, single2);
            Assert.AreEqual(0, many1);
            Assert.AreEqual(0, many2);
            Assert.AreEqual(0, many3);
            Assert.AreEqual(0, many4);
            Assert.AreEqual(0, single1_Destination);
            Assert.AreEqual(singleBefore.Single2, single2_Destination);
            Assert.AreEqual(singleBefore.Many1, many1_Destination);
            Assert.AreEqual(singleBefore.Many2, many2_Destination);
            Assert.AreEqual(0, many3_Destination);
            Assert.AreEqual(0, many4_Destination);
            Assert.AreEqual(singleBefore.Single1, single.Single1);
            Assert.AreEqual(singleBefore.Single2, single.Single2);
            Assert.AreEqual(singleBefore.Many1, single.Many1);
            Assert.AreEqual(singleBefore.Many2, single.Many2);
            Assert.AreEqual(singleBefore.Many3, single.Many3);
            Assert.AreEqual(singleBefore.Many4, single.Many4);
        }
Exemple #6
0
        public void Z_Test_0067()
        {
            // Title2: Map_Mapped

            Helper.CleanDatabase();

            var singleBefore = new EntitySimple_Mapper { Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40};
            var single = new EntitySimple_Mapper { Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40};

            using (var cn = Helper.GetConnection())
            {
                cn.Open();

                // PreTest

                // Action
                    Exception ex = null;
                    try
                    {
                       DapperPlusManager.Entity<EntitySimple_Mapper>("2a33f3fe-8ee0-4aa5-a4b7-bc83ba09d946").Map(x => x.Single1).Map(x => x.Single1);cn.BulkInsert("2a33f3fe-8ee0-4aa5-a4b7-bc83ba09d946", single);
                    }
                    catch(Exception exception)
                    {
                       ex = exception;
                    }
                    Assert.IsNotNull(ex);
                    Assert.AreEqual("One of your column have a destination mapped more then once. See the inner exception for details.", ex.Message);
                    return;
            }

            // GET count
            int single1 = 0;
            int single2 = 0;
            int many1 = 0;
            int many2 = 0;
            int many3 = 0;
            int many4 = 0;

            int single1_Destination = 0;
            int single2_Destination = 0;
            int many1_Destination = 0;
            int many2_Destination = 0;
            int many3_Destination = 0;
            int many4_Destination = 0;

            using (var connection = Helper.GetConnection())
            {
                connection.Open();

                using (var command = connection.CreateCommand())
                {

                command.CommandText = @"
                SELECT TOP 1
                        [Single1] ,
                        [Single2] ,
                        [Many1] ,
                        [Many2] ,
                        [Many3] ,
                        [Many4] ,
                        [Single1_Destination] ,
                        [Single2_Destination] ,
                        [Many1_Destination] ,
                        [Many2_Destination] ,
                        [Many3_Destination] ,
                        [Many4_Destination] " +
                    "FROM    [Z.Dapper.Plus].[dbo].[EntitySimple_TriggerOutput]";

                    using (var reader = command.ExecuteReader())
                    {
                        reader.Read();
                        single1 = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                        single2 = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                        many1 = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
                        many2 = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
                        many3 = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
                        many4 = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);

                        single1_Destination = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
                        single2_Destination = reader.IsDBNull(7) ? 0 : reader.GetInt32(7);
                        many1_Destination = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
                        many2_Destination = reader.IsDBNull(9) ? 0 : reader.GetInt32(9);
                        many3_Destination = reader.IsDBNull(10) ? 0 : reader.GetInt32(10);
                        many4_Destination = reader.IsDBNull(11) ? 0 : reader.GetInt32(11);
                    }
                }
            }

            // Test
        }
Exemple #7
0
        public void Z_Test_0026()
        {
            // Title2: IgnoreMany_IgnoreMany

            Helper.CleanDatabase();

            var singleBefore = new EntitySimple_Mapper {
                Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40
            };
            var single = new EntitySimple_Mapper {
                Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40
            };

            using (var cn = Helper.GetConnection())
            {
                cn.Open();

                // PreTest

                // Action
                DapperPlusManager.Entity <EntitySimple_Mapper>("6c7f0f9c-74a0-4ce7-8c9a-73fd49129c9f").Ignore(x => new { x.Many1, x.Many2 }).Ignore(x => new { x.Many3, x.Many4 }); cn.BulkInsert("6c7f0f9c-74a0-4ce7-8c9a-73fd49129c9f", single);
            }

            // GET count
            int single1 = 0;
            int single2 = 0;
            int many1   = 0;
            int many2   = 0;
            int many3   = 0;
            int many4   = 0;

            int single1_Destination = 0;
            int single2_Destination = 0;
            int many1_Destination   = 0;
            int many2_Destination   = 0;
            int many3_Destination   = 0;
            int many4_Destination   = 0;

            using (var connection = Helper.GetConnection())
            {
                connection.Open();

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = @"
				SELECT TOP 1
						[Single1] ,
						[Single2] ,
						[Many1] ,
						[Many2] ,
						[Many3] ,
						[Many4] ,
						[Single1_Destination] ,
						[Single2_Destination] ,
						[Many1_Destination] ,
						[Many2_Destination] ,
						[Many3_Destination] ,
						[Many4_Destination] "                         +
                                          "FROM    [Z.Dapper.Plus].[dbo].[EntitySimple_Mapper]";

                    using (var reader = command.ExecuteReader())
                    {
                        reader.Read();
                        single1 = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                        single2 = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                        many1   = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
                        many2   = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
                        many3   = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
                        many4   = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);

                        single1_Destination = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
                        single2_Destination = reader.IsDBNull(7) ? 0 : reader.GetInt32(7);
                        many1_Destination   = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
                        many2_Destination   = reader.IsDBNull(9) ? 0 : reader.GetInt32(9);
                        many3_Destination   = reader.IsDBNull(10) ? 0 : reader.GetInt32(10);
                        many4_Destination   = reader.IsDBNull(11) ? 0 : reader.GetInt32(11);
                    }
                }
            }

            // Test
            Assert.AreEqual(singleBefore.Single1, single1);
            Assert.AreEqual(singleBefore.Single2, single2);
            Assert.AreEqual(0, many1);
            Assert.AreEqual(0, many2);
            Assert.AreEqual(0, many3);
            Assert.AreEqual(0, many4);
            Assert.AreEqual(0, single1_Destination);
            Assert.AreEqual(0, single2_Destination);
            Assert.AreEqual(0, many1_Destination);
            Assert.AreEqual(0, many2_Destination);
            Assert.AreEqual(0, many3_Destination);
            Assert.AreEqual(0, many4_Destination);
            Assert.AreEqual(singleBefore.Single1, single.Single1);
            Assert.AreEqual(singleBefore.Single2, single.Single2);
            Assert.AreEqual(singleBefore.Many1, single.Many1);
            Assert.AreEqual(singleBefore.Many2, single.Many2);
            Assert.AreEqual(singleBefore.Many3, single.Many3);
            Assert.AreEqual(singleBefore.Many4, single.Many4);
        }
Exemple #8
0
        public void Z_Test_0056()
        {
            // Title2: OutputSingleDestination_OutputManyDestination

            Helper.CleanDatabase();

            var singleBefore = new EntitySimple_Mapper {
                Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40
            };
            var single = new EntitySimple_Mapper {
                Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40
            };

            using (var cn = Helper.GetConnection())
            {
                cn.Open();

                // PreTest

                // Action
                DapperPlusManager.Entity <EntitySimple_Mapper>("4747b1bd-fe0b-4f3b-86b6-b8e230764055").Table("EntitySimple_TriggerOutput").Output(x => x.Single1, "Single1_Destination").Output(x => new { Many3_Destination = x.Many3, Many4_Destination = x.Many4 }); cn.BulkInsert("4747b1bd-fe0b-4f3b-86b6-b8e230764055", single);
            }

            // GET count
            int single1 = 0;
            int single2 = 0;
            int many1   = 0;
            int many2   = 0;
            int many3   = 0;
            int many4   = 0;

            int single1_Destination = 0;
            int single2_Destination = 0;
            int many1_Destination   = 0;
            int many2_Destination   = 0;
            int many3_Destination   = 0;
            int many4_Destination   = 0;

            using (var connection = Helper.GetConnection())
            {
                connection.Open();

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = @"
				SELECT TOP 1
						[Single1] ,
						[Single2] ,
						[Many1] ,
						[Many2] ,
						[Many3] ,
						[Many4] ,
						[Single1_Destination] ,
						[Single2_Destination] ,
						[Many1_Destination] ,
						[Many2_Destination] ,
						[Many3_Destination] ,
						[Many4_Destination] "                         +
                                          "FROM    [Z.Dapper.Plus].[dbo].[EntitySimple_TriggerOutput]";

                    using (var reader = command.ExecuteReader())
                    {
                        reader.Read();
                        single1 = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                        single2 = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                        many1   = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
                        many2   = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
                        many3   = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
                        many4   = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);

                        single1_Destination = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
                        single2_Destination = reader.IsDBNull(7) ? 0 : reader.GetInt32(7);
                        many1_Destination   = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
                        many2_Destination   = reader.IsDBNull(9) ? 0 : reader.GetInt32(9);
                        many3_Destination   = reader.IsDBNull(10) ? 0 : reader.GetInt32(10);
                        many4_Destination   = reader.IsDBNull(11) ? 0 : reader.GetInt32(11);
                    }
                }
            }

            // Test
            Assert.AreEqual(-singleBefore.Single1 * 100, single.Single1);
            Assert.AreEqual(singleBefore.Single2, single.Single2);
            Assert.AreEqual(singleBefore.Many1, single.Many1);
            Assert.AreEqual(singleBefore.Many2, single.Many2);
            Assert.AreEqual(-singleBefore.Many3 * 100, single.Many3);
            Assert.AreEqual(-singleBefore.Many4 * 100, single.Many4);
        }
Exemple #9
0
        public void Z_Test_0078()
        {
            // Title2: OutputDestination_NotMapped

            Helper.CleanDatabase();

            var singleBefore = new EntitySimple_Mapper {
                Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40
            };
            var single = new EntitySimple_Mapper {
                Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40
            };

            using (var cn = Helper.GetConnection())
            {
                cn.Open();

                // PreTest

                // Action
                Exception ex = null;
                try
                {
                    DapperPlusManager.Entity <EntitySimple_Mapper>("2d8b65de-c5be-45b6-b863-079fce14c392").Map(x => x.Single1).Output(x => x.Single2, "Single2"); cn.BulkInsert("2d8b65de-c5be-45b6-b863-079fce14c392", single);
                }
                catch (Exception exception)
                {
                    ex = exception;
                }
                Assert.IsNotNull(ex);
                Assert.AreEqual("Specified cast is not valid.", ex.Message);
                return;
            }

            // GET count
            int single1 = 0;
            int single2 = 0;
            int many1   = 0;
            int many2   = 0;
            int many3   = 0;
            int many4   = 0;

            int single1_Destination = 0;
            int single2_Destination = 0;
            int many1_Destination   = 0;
            int many2_Destination   = 0;
            int many3_Destination   = 0;
            int many4_Destination   = 0;

            using (var connection = Helper.GetConnection())
            {
                connection.Open();

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = @"
				SELECT TOP 1
						[Single1] ,
						[Single2] ,
						[Many1] ,
						[Many2] ,
						[Many3] ,
						[Many4] ,
						[Single1_Destination] ,
						[Single2_Destination] ,
						[Many1_Destination] ,
						[Many2_Destination] ,
						[Many3_Destination] ,
						[Many4_Destination] "                         +
                                          "FROM    [Z.Dapper.Plus].[dbo].[EntitySimple_TriggerOutput]";

                    using (var reader = command.ExecuteReader())
                    {
                        reader.Read();
                        single1 = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                        single2 = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                        many1   = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
                        many2   = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
                        many3   = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
                        many4   = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);

                        single1_Destination = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
                        single2_Destination = reader.IsDBNull(7) ? 0 : reader.GetInt32(7);
                        many1_Destination   = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
                        many2_Destination   = reader.IsDBNull(9) ? 0 : reader.GetInt32(9);
                        many3_Destination   = reader.IsDBNull(10) ? 0 : reader.GetInt32(10);
                        many4_Destination   = reader.IsDBNull(11) ? 0 : reader.GetInt32(11);
                    }
                }
            }

            // Test
        }
Exemple #10
0
        public void Z_Test_0025()
        {
            // Title2: IgnoreMany_IgnoreSingle

            Helper.CleanDatabase();

            var singleBefore = new EntitySimple_Mapper { Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40};
            var single = new EntitySimple_Mapper { Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40};

            using (var cn = Helper.GetConnection())
            {
                cn.Open();

                // PreTest

                // Action
                DapperPlusManager.Entity<EntitySimple_Mapper>("39a6867a-61be-4aa6-b843-13ba580310a7").Ignore(x => new {x.Many1, x.Many2}).Ignore(x => x.Single2);cn.BulkInsert("39a6867a-61be-4aa6-b843-13ba580310a7", single);
            }

            // GET count
            int single1 = 0;
            int single2 = 0;
            int many1 = 0;
            int many2 = 0;
            int many3 = 0;
            int many4 = 0;

            int single1_Destination = 0;
            int single2_Destination = 0;
            int many1_Destination = 0;
            int many2_Destination = 0;
            int many3_Destination = 0;
            int many4_Destination = 0;

            using (var connection = Helper.GetConnection())
            {
                connection.Open();

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = @"
            SELECT TOP 1
            [Single1] ,
            [Single2] ,
            [Many1] ,
            [Many2] ,
            [Many3] ,
            [Many4] ,
            [Single1_Destination] ,
            [Single2_Destination] ,
            [Many1_Destination] ,
            [Many2_Destination] ,
            [Many3_Destination] ,
            [Many4_Destination]
            FROM    [Z.Dapper.Plus].[dbo].[EntitySimple_Mapper]";

                    using (var reader = command.ExecuteReader())
                    {
                        reader.Read();
                        single1 = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                        single2 = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                        many1 = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
                        many2 = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
                        many3 = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
                        many4 = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);

                        single1_Destination = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
                        single2_Destination = reader.IsDBNull(7) ? 0 : reader.GetInt32(7);
                        many1_Destination = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
                        many2_Destination = reader.IsDBNull(9) ? 0 : reader.GetInt32(9);
                        many3_Destination = reader.IsDBNull(10) ? 0 : reader.GetInt32(10);
                        many4_Destination = reader.IsDBNull(11) ? 0 : reader.GetInt32(11);
                    }
                }
            }

            // Test
            Assert.AreEqual(singleBefore.Single1, single1);
            Assert.AreEqual(0, single2);
            Assert.AreEqual(0, many1);
            Assert.AreEqual(0, many2);
            Assert.AreEqual(singleBefore.Many3, many3);
            Assert.AreEqual(singleBefore.Many4, many4);

            Assert.AreEqual(0, single1_Destination);
            Assert.AreEqual(0, single2_Destination);
            Assert.AreEqual(0, many1_Destination);
            Assert.AreEqual(0, many2_Destination);
            Assert.AreEqual(0, many3_Destination);
            Assert.AreEqual(0, many4_Destination);

            Assert.AreEqual(singleBefore.Single1, single.Single1);
            Assert.AreEqual(singleBefore.Single2, single.Single2);
            Assert.AreEqual(singleBefore.Many1, single.Many1);
            Assert.AreEqual(singleBefore.Many2, single.Many2);
            Assert.AreEqual(singleBefore.Many3, single.Many3);
            Assert.AreEqual(singleBefore.Many4, single.Many4);
        }
Exemple #11
0
        public void Z_Test_0074()
        {
            // Title2: Output_MappedDestination

            Helper.CleanDatabase();

            var singleBefore = new EntitySimple_Mapper { Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40};
            var single = new EntitySimple_Mapper { Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40};

            using (var cn = Helper.GetConnection())
            {
                cn.Open();

                // PreTest

                // Action
                    DapperPlusManager.Entity<EntitySimple_Mapper>("e9afc9fc-b5af-47df-bd32-d45647951add").Map(x => x.Single1, "Single1").Output(x => x.Single1);cn.BulkInsert("e9afc9fc-b5af-47df-bd32-d45647951add", single);
            }

            // GET count
            int single1 = 0;
            int single2 = 0;
            int many1 = 0;
            int many2 = 0;
            int many3 = 0;
            int many4 = 0;

            int single1_Destination = 0;
            int single2_Destination = 0;
            int many1_Destination = 0;
            int many2_Destination = 0;
            int many3_Destination = 0;
            int many4_Destination = 0;

            using (var connection = Helper.GetConnection())
            {
                connection.Open();

                using (var command = connection.CreateCommand())
                {

                command.CommandText = @"
                SELECT TOP 1
                        [Single1] ,
                        [Single2] ,
                        [Many1] ,
                        [Many2] ,
                        [Many3] ,
                        [Many4] ,
                        [Single1_Destination] ,
                        [Single2_Destination] ,
                        [Many1_Destination] ,
                        [Many2_Destination] ,
                        [Many3_Destination] ,
                        [Many4_Destination] " +
                    "FROM    [Z.Dapper.Plus].[dbo].[EntitySimple_Mapper]";

                    using (var reader = command.ExecuteReader())
                    {
                        reader.Read();
                        single1 = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                        single2 = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                        many1 = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
                        many2 = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
                        many3 = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
                        many4 = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);

                        single1_Destination = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
                        single2_Destination = reader.IsDBNull(7) ? 0 : reader.GetInt32(7);
                        many1_Destination = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
                        many2_Destination = reader.IsDBNull(9) ? 0 : reader.GetInt32(9);
                        many3_Destination = reader.IsDBNull(10) ? 0 : reader.GetInt32(10);
                        many4_Destination = reader.IsDBNull(11) ? 0 : reader.GetInt32(11);
                    }
                }
            }

            // Test
            Assert.AreEqual(singleBefore.Single1, single1);
            Assert.AreEqual(0, single2);
            Assert.AreEqual(0, many1);
            Assert.AreEqual(0, many2);
            Assert.AreEqual(0, many3);
            Assert.AreEqual(0, many4);
            Assert.AreEqual(0, single1_Destination);
            Assert.AreEqual(0, single2_Destination);
            Assert.AreEqual(0, many1_Destination);
            Assert.AreEqual(0, many2_Destination);
            Assert.AreEqual(0, many3_Destination);
            Assert.AreEqual(0, many4_Destination);
            Assert.AreEqual(singleBefore.Single1, single.Single1);
            Assert.AreEqual(singleBefore.Single2, single.Single2);
            Assert.AreEqual(singleBefore.Many1, single.Many1);
            Assert.AreEqual(singleBefore.Many2, single.Many2);
            Assert.AreEqual(singleBefore.Many3, single.Many3);
            Assert.AreEqual(singleBefore.Many4, single.Many4);
        }
Exemple #12
0
        public void Z_Test_0077()
        {
            // Title2: Output_NotMapped

            Helper.CleanDatabase();

            var singleBefore = new EntitySimple_Mapper { Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40};
            var single = new EntitySimple_Mapper { Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40};

            using (var cn = Helper.GetConnection())
            {
                cn.Open();

                // PreTest

                // Action
                    Exception ex = null;
                    try
                    {
                       DapperPlusManager.Entity<EntitySimple_Mapper>("42190a57-70b7-42ae-83b6-671cf622c3e2").Map(x => x.Single1).Output(x => x.Single2);cn.BulkInsert("42190a57-70b7-42ae-83b6-671cf622c3e2", single);
                    }
                    catch(Exception exception)
                    {
                       ex = exception;
                    }
                    Assert.IsNotNull(ex);
                    Assert.AreEqual("Specified cast is not valid.", ex.Message);
                    return;
            }

            // GET count
            int single1 = 0;
            int single2 = 0;
            int many1 = 0;
            int many2 = 0;
            int many3 = 0;
            int many4 = 0;

            int single1_Destination = 0;
            int single2_Destination = 0;
            int many1_Destination = 0;
            int many2_Destination = 0;
            int many3_Destination = 0;
            int many4_Destination = 0;

            using (var connection = Helper.GetConnection())
            {
                connection.Open();

                using (var command = connection.CreateCommand())
                {

                command.CommandText = @"
                SELECT TOP 1
                        [Single1] ,
                        [Single2] ,
                        [Many1] ,
                        [Many2] ,
                        [Many3] ,
                        [Many4] ,
                        [Single1_Destination] ,
                        [Single2_Destination] ,
                        [Many1_Destination] ,
                        [Many2_Destination] ,
                        [Many3_Destination] ,
                        [Many4_Destination] " +
                    "FROM    [Z.Dapper.Plus].[dbo].[EntitySimple_TriggerOutput]";

                    using (var reader = command.ExecuteReader())
                    {
                        reader.Read();
                        single1 = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                        single2 = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                        many1 = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
                        many2 = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
                        many3 = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
                        many4 = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);

                        single1_Destination = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
                        single2_Destination = reader.IsDBNull(7) ? 0 : reader.GetInt32(7);
                        many1_Destination = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
                        many2_Destination = reader.IsDBNull(9) ? 0 : reader.GetInt32(9);
                        many3_Destination = reader.IsDBNull(10) ? 0 : reader.GetInt32(10);
                        many4_Destination = reader.IsDBNull(11) ? 0 : reader.GetInt32(11);
                    }
                }
            }

            // Test
        }
Exemple #13
0
        public void Z_Test_0020()
        {
            // Title2: MapManyDestination_MapManyDestination

            Helper.CleanDatabase();

            var singleBefore = new EntitySimple_Mapper {
                Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40
            };
            var single = new EntitySimple_Mapper {
                Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40
            };

            using (var cn = Helper.GetConnection())
            {
                cn.Open();

                // PreTest

                // Action
                DapperPlusManager.Entity <EntitySimple_Mapper>("3a314fe0-0c49-45a2-af2b-31708e3b62b4").Map(x => new { Many1_Destination = x.Many1, Many2_Destination = x.Many2 }).Map(x => new { Many3_Destination = x.Many3, Many4_Destination = x.Many4 }); cn.BulkInsert("3a314fe0-0c49-45a2-af2b-31708e3b62b4", single);
            }

            // GET count
            int single1 = 0;
            int single2 = 0;
            int many1   = 0;
            int many2   = 0;
            int many3   = 0;
            int many4   = 0;

            int single1_Destination = 0;
            int single2_Destination = 0;
            int many1_Destination   = 0;
            int many2_Destination   = 0;
            int many3_Destination   = 0;
            int many4_Destination   = 0;

            using (var connection = Helper.GetConnection())
            {
                connection.Open();

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = @"
SELECT TOP 1
        [Single1] ,
        [Single2] ,
        [Many1] ,
        [Many2] ,
        [Many3] ,
        [Many4] ,
        [Single1_Destination] ,
        [Single2_Destination] ,
        [Many1_Destination] ,
        [Many2_Destination] ,
        [Many3_Destination] ,
        [Many4_Destination]
FROM    [Z.Dapper.Plus].[dbo].[EntitySimple_Mapper]";

                    using (var reader = command.ExecuteReader())
                    {
                        reader.Read();
                        single1 = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                        single2 = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                        many1   = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
                        many2   = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
                        many3   = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
                        many4   = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);

                        single1_Destination = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
                        single2_Destination = reader.IsDBNull(7) ? 0 : reader.GetInt32(7);
                        many1_Destination   = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
                        many2_Destination   = reader.IsDBNull(9) ? 0 : reader.GetInt32(9);
                        many3_Destination   = reader.IsDBNull(10) ? 0 : reader.GetInt32(10);
                        many4_Destination   = reader.IsDBNull(11) ? 0 : reader.GetInt32(11);
                    }
                }
            }

            // Test
            Assert.AreEqual(0, single1);
            Assert.AreEqual(0, single2);
            Assert.AreEqual(0, many1);
            Assert.AreEqual(0, many2);
            Assert.AreEqual(0, many3);
            Assert.AreEqual(0, many4);

            Assert.AreEqual(0, single1_Destination);
            Assert.AreEqual(0, single2_Destination);
            Assert.AreEqual(singleBefore.Many1, many1_Destination);
            Assert.AreEqual(singleBefore.Many2, many2_Destination);
            Assert.AreEqual(singleBefore.Many3, many3_Destination);
            Assert.AreEqual(singleBefore.Many4, many4_Destination);

            Assert.AreEqual(singleBefore.Single1, single.Single1);
            Assert.AreEqual(singleBefore.Single2, single.Single2);
            Assert.AreEqual(singleBefore.Many1, single.Many1);
            Assert.AreEqual(singleBefore.Many2, single.Many2);
            Assert.AreEqual(singleBefore.Many3, single.Many3);
            Assert.AreEqual(singleBefore.Many4, single.Many4);
        }
Exemple #14
0
        public void Z_Test_0070()
        {
            // Title2: MapDestination_MappedDestination

            Helper.CleanDatabase();

            var singleBefore = new EntitySimple_Mapper {
                Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40
            };
            var single = new EntitySimple_Mapper {
                Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40
            };

            using (var cn = Helper.GetConnection())
            {
                cn.Open();

                // PreTest

                // Action
                Exception ex = null;
                try
                {
                    DapperPlusManager.Entity <EntitySimple_Mapper>("b6dc0ae6-0cb2-417c-ab4b-eeb24b75de7c").Map(x => x.Single1, "Single1").Map(x => x.Single1, "Single1"); cn.BulkInsert("b6dc0ae6-0cb2-417c-ab4b-eeb24b75de7c", single);
                }
                catch (Exception exception)
                {
                    ex = exception;
                }
                Assert.IsNotNull(ex);
                Assert.AreEqual("One of your column have a destination mapped more then once. See the inner exception for details.", ex.Message);
                return;
            }

            // GET count
            int single1 = 0;
            int single2 = 0;
            int many1   = 0;
            int many2   = 0;
            int many3   = 0;
            int many4   = 0;

            int single1_Destination = 0;
            int single2_Destination = 0;
            int many1_Destination   = 0;
            int many2_Destination   = 0;
            int many3_Destination   = 0;
            int many4_Destination   = 0;

            using (var connection = Helper.GetConnection())
            {
                connection.Open();

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = @"
				SELECT TOP 1
						[Single1] ,
						[Single2] ,
						[Many1] ,
						[Many2] ,
						[Many3] ,
						[Many4] ,
						[Single1_Destination] ,
						[Single2_Destination] ,
						[Many1_Destination] ,
						[Many2_Destination] ,
						[Many3_Destination] ,
						[Many4_Destination] "                         +
                                          "FROM    [Z.Dapper.Plus].[dbo].[EntitySimple_TriggerOutput]";

                    using (var reader = command.ExecuteReader())
                    {
                        reader.Read();
                        single1 = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                        single2 = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                        many1   = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
                        many2   = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
                        many3   = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
                        many4   = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);

                        single1_Destination = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
                        single2_Destination = reader.IsDBNull(7) ? 0 : reader.GetInt32(7);
                        many1_Destination   = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
                        many2_Destination   = reader.IsDBNull(9) ? 0 : reader.GetInt32(9);
                        many3_Destination   = reader.IsDBNull(10) ? 0 : reader.GetInt32(10);
                        many4_Destination   = reader.IsDBNull(11) ? 0 : reader.GetInt32(11);
                    }
                }
            }

            // Test
        }
Exemple #15
0
        public void Z_Test_0039()
        {
            // Title2: IdentityMany_IdentitySingleDestination

            Helper.CleanDatabase();

            var singleBefore = new EntitySimple_Mapper { Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40};
            var single = new EntitySimple_Mapper { Single1 = 1, Single2 = 2, Many1 = 10, Many2 = 20, Many3 = 30, Many4 = 40};

            using (var cn = Helper.GetConnection())
            {
                cn.Open();

                // PreTest

                // Action
                    DapperPlusManager.Entity<EntitySimple_Mapper>("8f841f7c-c555-4553-9cb6-9985db1b3eb0").Table("EntitySimple_TriggerOutput").Identity(x => new {x.Many1, x.Many2}).Identity(x => x.Single2, "Single2_Destination");cn.BulkInsert("8f841f7c-c555-4553-9cb6-9985db1b3eb0", single);
            }

            // GET count
            int single1 = 0;
            int single2 = 0;
            int many1 = 0;
            int many2 = 0;
            int many3 = 0;
            int many4 = 0;

            int single1_Destination = 0;
            int single2_Destination = 0;
            int many1_Destination = 0;
            int many2_Destination = 0;
            int many3_Destination = 0;
            int many4_Destination = 0;

            using (var connection = Helper.GetConnection())
            {
                connection.Open();

                using (var command = connection.CreateCommand())
                {

                command.CommandText = @"
                SELECT TOP 1
                        [Single1] ,
                        [Single2] ,
                        [Many1] ,
                        [Many2] ,
                        [Many3] ,
                        [Many4] ,
                        [Single1_Destination] ,
                        [Single2_Destination] ,
                        [Many1_Destination] ,
                        [Many2_Destination] ,
                        [Many3_Destination] ,
                        [Many4_Destination] " +
                    "FROM    [Z.Dapper.Plus].[dbo].[EntitySimple_TriggerOutput]";

                    using (var reader = command.ExecuteReader())
                    {
                        reader.Read();
                        single1 = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
                        single2 = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
                        many1 = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);
                        many2 = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);
                        many3 = reader.IsDBNull(4) ? 0 : reader.GetInt32(4);
                        many4 = reader.IsDBNull(5) ? 0 : reader.GetInt32(5);

                        single1_Destination = reader.IsDBNull(6) ? 0 : reader.GetInt32(6);
                        single2_Destination = reader.IsDBNull(7) ? 0 : reader.GetInt32(7);
                        many1_Destination = reader.IsDBNull(8) ? 0 : reader.GetInt32(8);
                        many2_Destination = reader.IsDBNull(9) ? 0 : reader.GetInt32(9);
                        many3_Destination = reader.IsDBNull(10) ? 0 : reader.GetInt32(10);
                        many4_Destination = reader.IsDBNull(11) ? 0 : reader.GetInt32(11);
                    }
                }
            }

            // Test
            Assert.AreEqual(singleBefore.Single1, single.Single1);
            Assert.AreEqual(-singleBefore.Single2*100, single.Single2);
            Assert.AreEqual(-singleBefore.Many1, single.Many1);
            Assert.AreEqual(-singleBefore.Many2, single.Many2);
            Assert.AreEqual(singleBefore.Many3, single.Many3);
            Assert.AreEqual(singleBefore.Many4, single.Many4);
        }