コード例 #1
0
 public static object GetSampleListOrderByDesc(Func <ISampleBaseInfo, bool> whereLambda = null, Func <ISampleBaseInfo, object> orderbyLamba = null, int PageId = 1, int PageSize = 20)
 {
     if (orderbyLamba == null)
     {
         orderbyLamba = p => p.State;
     }
     if (whereLambda == null)
     {
         whereLambda = (p => true);
     }
     using (SunginDataContext sc = new SunginDataContext())
     {
         int count = sc.SampleBaseInfos.Count(whereLambda);
         List <ISampleBaseInfo> sampleinfo = sc.SampleBaseInfos.Where(whereLambda).OrderByDescending(orderbyLamba).ThenByDescending(p => p.Id).Skip(PageSize * (PageId - 1)).Take(PageSize).ToList();
         List <object>          obj        = new List <object>();
         sampleinfo.ForEach(p =>
         {
             obj.Add(SampleHelper.GetReturnObj(p));
         });
         return(new { items = obj, total = count, current = PageId, pageSize = PageSize });
     }
 }