コード例 #1
0
        public void TestC_Query4()
        {
            //带条件查询多个对象
            var result = DbHelp.QueryList <EmployeeModel>("select * from employee e where e.Status=20 and", new { e_Age_ge = 48 }, SugarCommandType.QuerySelectSql).ToList();

            Assert.AreEqual(1, result.Count, "带条件查询多个对象错误");

            Assert.AreEqual(1, result[0].Id, "带条件查询多个对象错误");
        }
コード例 #2
0
        public void TestC_Query2()
        {
            //查询多个对象
            var result = DbHelp.QueryList <EmployeeModel>("employee", new { Age_ge = 50, Age_le = 50 }, SugarCommandType.QueryTableDirect).ToList();

            Assert.AreEqual(1, result.Count, "查询多个对象");

            Assert.AreEqual(1, result[0].Id, "查询多个对象");
        }
コード例 #3
0
        public void TestC_Query3()
        {
            //别名查询多个对象
            //new { ue_e_Id = 1, ge_e_Age = 48 }
            var param = new { e_Id_ue = 1, e_Age_ge = 48 };
            //dynamic param = new ExpandoObject();
            //param.e_Age_ge = 48;
            //param.ue_e_Id = 1;
            //param.ge_e_Age = 48;
            var result = DbHelp.QueryList <EmployeeModel>("select * from employee e where", param, SugarCommandType.QuerySelectSql).ToList();

            Assert.AreEqual(1, result.Count, "别名查询多个对象错误");

            Assert.AreEqual(2, result[0].Id, "别名查询多个对象错误");
        }