예제 #1
0
        public void TestD_StoredProcedure2()
        {
            //存储过程,根据存储名称调用存储过程
            var result = DbHelp.ExecuteSql("delete_data", new { startId = 6 }, SugarCommandType.StoredProcedure);

            Assert.AreEqual(0, result, "调用存储过程错误");
        }
예제 #2
0
        public void TestD_StoredProcedure1()
        {
            //存储过程,根据存储名称调用存储过程
            var p = new DynamicParameters();

            p.Add("@startId", 6);

            var result = DbHelp.ExecuteSql("delete_data", p, SugarCommandType.StoredProcedure);

            Assert.AreEqual(7, result, "调用存储过程错误");
        }
예제 #3
0
        public void TestB_Update2()
        {
            var employeeList = new List <EmployeeModel>
            {
                new EmployeeModel
                {
                    Id      = 1,
                    Account = "songjiang",
                    Name    = "宋江",
                    Age     = 50,
                    Status  = EmployeeModel.EnumStatus.Complate
                },
                new EmployeeModel
                {
                    Id      = 2,
                    Account = "lujunyi",
                    Name    = "卢俊义",
                    Age     = 48,
                    Status  = EmployeeModel.EnumStatus.Disable
                }
            };

            using (var conn = DbHelp.DbProvider.CreateConnection())
            {
                var result = DbHelp.ExecuteSql("employee", employeeList, SugarCommandType.UpdateTableDirect);

                var addlist = DbHelp.DbProvider.QueryList <EmployeeModel>(conn, "employee", new { Id = new int[] { 1, 2 } }, SugarCommandType.QueryTableDirect, "Order By Id Asc").ToList();

                Assert.AreEqual(2, result, "修改-表名-多个实体对象");

                Assert.IsTrue(addlist.Count == 2 &&
                              addlist[0].Account == employeeList[0].Account &&
                              addlist[0].Name == employeeList[0].Name &&
                              addlist[0].Age == employeeList[0].Age &&
                              addlist[0].Status == employeeList[0].Status

                              && addlist[1].Account == employeeList[1].Account &&
                              addlist[1].Name == employeeList[1].Name &&
                              addlist[1].Age == employeeList[1].Age &&
                              addlist[1].Status == employeeList[1].Status
                              , "修改-表名-多个实体对象");
            }
        }