public void TestD_Delete2() { //存储过程,根据存储名称调用存储过程 var result = DbHelp.ExecuteSql("delete from employee where Id > @startId", new { startId = 6 }, SugarCommandType.Text); Assert.AreEqual(result, 0, "调用删除错误"); }
public void TestD_Delete1() { //存储过程,根据存储名称调用存储过程 var p = new DynamicParameters(); p.Add("@startId", 6, System.Data.DbType.Int32, System.Data.ParameterDirection.Input); var result = DbHelp.ExecuteSql("delete from employee where Id > @startId", p, SugarCommandType.Text); Assert.AreEqual(result, 7, "调用删除错误"); }
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 , "修改-表名-多个实体对象"); } }