EF

来源:互联网 发布:华为无法访问移动网络 编辑:程序博客网 时间:2024/05/01 01:21
using System;using System.Collections.Generic;using System.Linq;using System.Linq.Expressions;using System.Text;using System.Threading.Tasks;namespace t1_Back{    class Program    {        static void Main(string[] args)        {            Heima90AEntities context = new Heima90AEntities();            // context            string  s = "a";            Console.ReadKey();        }            static List<dynamic> GetPageList<T,TKey>(Expression<Func<T,dynamic>> select1,            Expression<Func<T,bool>> where,            Expression<Func<T,TKey>> order,int pageSize,            int pageIndex,out int total,bool isAsc)            where T:class        {            Heima90AEntities context = new Heima90AEntities();            total = context.Set<T>().Where(where).Count();            var result = context.Set<T>().Where(where);            if (isAsc)            {                result = result.OrderBy(order);            }            else            {                result = result.OrderByDescending(order);            }            return result.Skip((pageIndex-1)*pageSize).Take(pageSize).Select(select1).ToList();                   }    }}

0 0