Suggest

Jan 3, 2010 at 7:05 AM

public static PageModel<T> FindByPage<T, TKey>(this DbObjectModel<T, TKey> obj, Expression<Func<T, bool>> condition, Expression<Func<T, object>> orderby, int pagesize, int pagenumber) where T : DbObjectModel<T, TKey>
        {
            var r = new PageModel<T>();
            var IP = DbEntry.From<T>().Where(condition).OrderByDescending(orderby).PageSize(pagesize).GetPagedSelector();
            r.PageSize = IP.PageSize;
            r.RecordCount = IP.GetResultCount();
            r.PageNumber = pagenumber;
            r.list = (List<T>)IP.GetCurrentPage(r.PageNumber - 1);
            return r;
        }

 

 

public class PageModel<T> where T : class, IDbObject
    {
        public List<T> list { get; set; }

        public int PageNumber { get; set; }

        public long RecordCount { get; set; }

        public int PageSize { get; set; }

    }

 

建议增加一个静态方法

 

因为c#不支持静态扩展

Jan 3, 2010 at 7:43 AM

刚发现了,老大已经有了一个ItemList类了

PageModel多余了