苏飞论坛

标题: 新的框架使用方式一览 [打印本页]

作者: 站长苏飞    时间: 2019-1-18 16:21
标题: 新的框架使用方式一览
[C#] 纯文本查看 复制代码
  Hr_EmployeeBLL hr_el = new Hr_EmployeeBLL();

            //------------------------------------------------------查询------------------------------------------------------------------------
            //查询所有
            List<Hr_Employee> list = hr_el.FindList();

            //根据条件查询
            list = hr_el.FindList("UserID=232");

            //根据条件查询  支持直接自己写SQl语句
            list = hr_el.FindList("select top 5 * from Hr_Employee where UserID<>@UserID", DictBuilder.Assign("UserID", 109));

            //根据条件查询 参数必须出现在语句中
            list = hr_el.FindList("UserID=@UserID and Password=@Password", DictBuilder.Assign("UserID", 233).Assign("Password", 12345));

            //根据条件查询 自动组织参数
            list = hr_el.FindListWhere(DictBuilder.Assign("Password", "12345").IN("UserID", new int[] { 233, 1180, 326, 325 }));

            long totalcount = 0;
            //根据条件查询-分页
            list = hr_el.FindListPage(
                new OrmLitePageFactor()
                {
                    Conditions = "UserID<>@UserID",
                    OrderBy = "UserID desc",
                    PageIndex = 2,
                    PageSize = 20,
                    Params = DictBuilder.Assign("UserID", 109)
                },
                out totalcount);

            //------------------------------------------------------写入------------------------------------------------------------------------
            Hr_Employee obj = new Hr_Employee()
            {
                Birthday = string.Empty,
                BranchID = 1,
                CheckinDate = DateTime.Now,
                UserName = "sufei"
            };
            //long userid = hr_el.Insert(obj, true);
            //------------------------------------------------------修改------------------------------------------------------------------------
            int result = 0;

            obj = new Hr_Employee()
            {
                Birthday = string.Empty,
                CheckinDate = DateTime.Now,
                UserName = "sufei"
            };
             //result = hr_el.Update(obj, new string[] { "Birthday", "UserName", "CheckinDate" });

            //条件修改
            result = hr_el.Update(
               DictBuilder.Assign("UserName", "sufei"), "UserName=@UserName1",
               DictBuilder.Assign("UserName1", "sufei"));
            //------------------------------------------------------删除------------------------------------------------------------------------

            //result = hr_el.Delete("UserName=@UserName", DictBuilder.Assign("UserName", "sufei"));

            //------------------------------------------------------其他------------------------------------------------------------------------
            long countall = hr_el.Count();//总行
            long count = hr_el.Count("UserID<>@UserID", DictBuilder.Assign("UserID", 1516));//sql查询
            count = hr_el.Count("UserID<>1516");//单SQl查询


作者: Amy    时间: 2019-1-18 16:23
强烈支持楼主ing……
作者: 竹林风    时间: 2019-1-18 17:31
感恩无私的分享与奉献
作者: 乖乖    时间: 2019-2-19 10:54
真是被感动的痛哭流涕……
作者: gaomanxiang    时间: 2019-3-18 23:16
感恩无私的分享与奉献   +1
真是被感动的痛哭流涕……  +1
作者: xhdyhzw    时间: 2020-3-28 21:07
支持多表关联查询和视图查询?
作者: 1486969608    时间: 2020-10-12 22:11
本帖最后由 1486969608 于 2020-10-12 22:17 编辑

优秀,学起来!哈哈




欢迎光临 苏飞论坛 (http://www.sufeinet.com/) Powered by Discuz! X3.4