Пример #1
0
        // 分页条件查询
        public PageData <Student> GetData(string Name, string Tel, int PageIndex = 1, int PageSize = 3)
        {
            PageData <Student> pd = new PageData <Student>();

            pd.PageSize = PageSize;


            int    start = (PageIndex - 1) * PageSize + 1;
            int    end   = PageIndex * PageSize;
            string sql   = "from Student where 1=1 ";

            if (!string.IsNullOrWhiteSpace(Name))
            {
                sql += $" and Name like '%{Name}%'";
            }

            if (!string.IsNullOrWhiteSpace(Tel))
            {
                sql += $" and Tel like '%{Tel}%'";
            }



            // SQL 设置好查询条件 获取总记录数 ,,
            pd.TotalRecord = DBhelper <Student> .GetData("select * " + sql).Count();

            // Sql 设置好分页,获取当前页记录
            var pageSql = "select * from ( select Row_number() over(order by Id) as No, * " +
                          sql +
                          $") T  where T.No between {start} and {end}";

            pd.Data = DBhelper <Student> .GetData(pageSql);

            return(pd);
        }
Пример #2
0
        public string GetUrl(string Name)
        {
            string sql = $"select * from UserInfo where Name='{Name}'";

            return(DBhelper <UserInfo> .GetData(sql).FirstOrDefault()?.Url);
        }
Пример #3
0
        public UserInfo Login(string Name, string Pass)
        {
            string sql = $"select * from UserInfo where Name='{Name}' and Pass = '******'";

            return(DBhelper <UserInfo> .GetData(sql).FirstOrDefault());
        }