public void Z_Test_0029() { // Title2: IdentitySingle_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>("2f866618-aa1e-43b7-9e5a-9aefc70af5f2").Table("EntitySimple_TriggerOutput").Identity(x => x.Single1).Identity(x => x.Single2, "Single2_Destination"); cn.BulkInsert("2f866618-aa1e-43b7-9e5a-9aefc70af5f2", 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); }
public void Z_Test_0010() { Helper.CleanDatabase(); var single1 = new SingleMany { ColumnInt = 1 }; var single2 = new SingleMany { ColumnInt = 8 }; var single3 = new SingleMany { ColumnInt = 64 }; var many1 = new List <SingleMany> { new SingleMany { ColumnInt = 512 }, new SingleMany { ColumnInt = 1024 }, new SingleMany { ColumnInt = 2048 } }; var many2 = new List <SingleMany> { new SingleMany { ColumnInt = 4096 }, new SingleMany { ColumnInt = 8192 }, new SingleMany { ColumnInt = 16384 } }; var many3 = new List <SingleMany> { new SingleMany { ColumnInt = 32768 }, new SingleMany { ColumnInt = 65536 }, new SingleMany { ColumnInt = 131072 } }; Helper.LinkSingleMany(single1, single2, single3, many1, many2, many3); Helper.InsertFromMetas("".Split(';').ToList(), single1, single2, single3, many1, many2, many3); Helper.UpdateFromMetas("".Split(';').ToList(), single1, single2, single3, many1, many2, many3); // GET count before int columnInt_before = 0; int columnUpdateInt_before = 0; int columnInt_Key_before = 0; int columnUpdateInt_Key_before = 0; using (var connection = Helper.GetConnection()) { connection.Open(); using (var command = connection.CreateCommand()) { command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnInt) FROM SingleMany), 0)"; columnInt_before = Convert.ToInt32(command.ExecuteScalar()); command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnUpdateInt) FROM SingleMany), 0)"; columnUpdateInt_before = Convert.ToInt32(command.ExecuteScalar()); command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnInt) FROM SingleMany_Key), 0)"; columnInt_Key_before = Convert.ToInt32(command.ExecuteScalar()); command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnUpdateInt) FROM SingleMany_Key), 0)"; columnUpdateInt_Key_before = Convert.ToInt32(command.ExecuteScalar()); } } using (var cn = Helper.GetConnection()) { cn.Open(); // PreTest // Action cn.BulkInsert("key", single1).AlsoBulkInsert("key", x => x.Many1, x => x.Many2, x => x.Many3); } // GET count int columnInt = 0; int columnUpdateInt = 0; int columnInt_Key = 0; int columnUpdateInt_Key = 0; using (var connection = Helper.GetConnection()) { connection.Open(); using (var command = connection.CreateCommand()) { command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnInt) FROM SingleMany), 0)"; columnInt = Convert.ToInt32(command.ExecuteScalar()); command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnUpdateInt) FROM SingleMany), 0)"; columnUpdateInt = Convert.ToInt32(command.ExecuteScalar()); command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnInt) FROM SingleMany_Key), 0)"; columnInt_Key = Convert.ToInt32(command.ExecuteScalar()); command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnUpdateInt) FROM SingleMany_Key), 0)"; columnUpdateInt_Key = Convert.ToInt32(command.ExecuteScalar()); } } // Test Assert.AreEqual(0, columnInt); Assert.AreEqual(0, columnUpdateInt); Assert.AreEqual(single1.ColumnInt + many1.Sum(x => x.ColumnInt) + many2.Sum(x => x.ColumnInt) + many3.Sum(x => x.ColumnInt), columnInt_Key); Assert.AreEqual(0, columnUpdateInt_Key); }
public async Task Z_Test_0057() { Helper.CleanDatabase(); var single1 = new SingleMany { ColumnInt = 1 }; var single2 = new SingleMany { ColumnInt = 8 }; var single3 = new SingleMany { ColumnInt = 64 }; var many1 = new List <SingleMany> { new SingleMany { ColumnInt = 512 }, new SingleMany { ColumnInt = 1024 }, new SingleMany { ColumnInt = 2048 } }; var many2 = new List <SingleMany> { new SingleMany { ColumnInt = 4096 }, new SingleMany { ColumnInt = 8192 }, new SingleMany { ColumnInt = 16384 } }; var many3 = new List <SingleMany> { new SingleMany { ColumnInt = 32768 }, new SingleMany { ColumnInt = 65536 }, new SingleMany { ColumnInt = 131072 } }; Helper.LinkSingleMany(single1, single2, single3, many1, many2, many3); Helper.InsertFromMetas("BulkInsertAll;UpdateValueAll".Split(';').ToList(), single1, single2, single3, many1, many2, many3); Helper.UpdateFromMetas("BulkInsertAll;UpdateValueAll".Split(';').ToList(), single1, single2, single3, many1, many2, many3); // GET count before int columnInt_before = 0; int columnUpdateInt_before = 0; int columnInt_Key_before = 0; int columnUpdateInt_Key_before = 0; using (var connection = Helper.GetConnection()) { connection.Open(); using (var command = connection.CreateCommand()) { command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnInt) FROM SingleMany), 0)"; columnInt_before = Convert.ToInt32(command.ExecuteScalar()); command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnUpdateInt) FROM SingleMany), 0)"; columnUpdateInt_before = Convert.ToInt32(command.ExecuteScalar()); command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnInt) FROM SingleMany_Key), 0)"; columnInt_Key_before = Convert.ToInt32(command.ExecuteScalar()); command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnUpdateInt) FROM SingleMany_Key), 0)"; columnUpdateInt_Key_before = Convert.ToInt32(command.ExecuteScalar()); } } using (var cn = Helper.GetConnection()) { cn.Open(); // PreTest // Action await cn.BulkActionAsync(action => action.BulkUpdate("key", single1, single2, single3)); } // GET count int columnInt = 0; int columnUpdateInt = 0; int columnInt_Key = 0; int columnUpdateInt_Key = 0; using (var connection = Helper.GetConnection()) { connection.Open(); using (var command = connection.CreateCommand()) { command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnInt) FROM SingleMany), 0)"; columnInt = Convert.ToInt32(command.ExecuteScalar()); command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnUpdateInt) FROM SingleMany), 0)"; columnUpdateInt = Convert.ToInt32(command.ExecuteScalar()); command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnInt) FROM SingleMany_Key), 0)"; columnInt_Key = Convert.ToInt32(command.ExecuteScalar()); command.CommandText = "SELECT ISNULL((SELECT SUM(ColumnUpdateInt) FROM SingleMany_Key), 0)"; columnUpdateInt_Key = Convert.ToInt32(command.ExecuteScalar()); } } // Test Assert.AreEqual(columnInt_before, columnInt); Assert.AreEqual(columnUpdateInt_before, columnUpdateInt); Assert.AreEqual(columnInt_Key_before, columnInt_Key); Assert.AreEqual(single1.ColumnInt + single2.ColumnInt + single3.ColumnInt, columnUpdateInt_Key); }
public void Z_Test_0008() { // Title2: MapSingleDestination_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>("88e171db-5ddf-4ab6-a8ff-16f9371edf4b").Map(x => x.Single1, "Single1_Destination").Map(x => x.Single2, "Single2_Destination"); cn.BulkInsert("88e171db-5ddf-4ab6-a8ff-16f9371edf4b", 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(singleBefore.Single1, single1_Destination); Assert.AreEqual(singleBefore.Single2, 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); }
public void Z_Test_0023() { // Title2: IgnoreSingle_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>("4ec6f89b-48bc-4d01-9c3d-82f2c7e3aa6f").Ignore(x => x.Single1).Ignore(x => new { x.Many3, x.Many4 }); cn.BulkInsert("4ec6f89b-48bc-4d01-9c3d-82f2c7e3aa6f", 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(singleBefore.Single2, single2); Assert.AreEqual(singleBefore.Many1, many1); Assert.AreEqual(singleBefore.Many2, 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); }
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); }
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 }
public void Z_Test_0058() { // Title2: OutputMany_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>("b8d816a4-96d3-4365-908e-f951c4edb1af").Table("EntitySimple_TriggerOutput").Output(x => new { x.Many1, x.Many2 }).Output(x => x.Single2); cn.BulkInsert("b8d816a4-96d3-4365-908e-f951c4edb1af", 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); }
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 }