zoukankan      html  css  js  c++  java
  • .net下MVC中使用Tuple分页查询数据

    主要是在DAL层写查询分页的代码。

    例如DAL层上代码:

    public Tuple<List<WxBindDto>, int> GetMbersInfo(int start, int length, ExtGridSearch condition, Guid sid, Guid accountId, string selbrand)
    {
    List<WxBindDto> wd = new List<WxBindDto>();
    System.Linq.Expressions.Expression<Func<Mall_Shop, bool>> infoWhere = f => f.AccountId == accountId;

    if (!string.IsNullOrEmpty(selbrand))
    {
    infoWhere = infoWhere.And(x => x.BrandIds == selbrand);
    }
    var vipList = (from lt in base._db.VIPWxBind.Where(v => v.AccountId == accountId && v.SId == sid)
    join vi in base._db.VIPInfo.Where(x => x.AccountId == accountId) on lt.MobilePhone equals vi.MobilePhone
    join ms in base._db.MallShop.Where(infoWhere) on vi.ShopNO equals ms.ShopNo
    select new WxBindDto
    {
    Id = lt.Id,
    }).OrderByDescending(v => v.CreateTime);
    int count = vipList.Count();
    wd = vipList.Skip(start).Take(length).ToList();
    return Tuple.Create(wd, count);
    }

    在IDAL 、BLL层只需要调用一下就行了,跳过。。。。

    最后在Controller层,例如调用代码:

    var rst = xxx.xxxx.GetMbersInfo(start, length, condition, sid, accountId, selbrand);

    得到的rst就是返回来的结果。

    使用rst.Item1得到的是一个查询数据的集合。

    使用rst.Item2得到的是一个根据条件查询数据的条数。

    即:在DAL层wd、count对应Item1、Item2

  • 相关阅读:
    MySql常用函数积累
    常用的linux命令
    Java replace和replaceAll
    json常用操作
    import { Subject } from 'rxjs/Subject';
    applicationCache
    mongo
    Mongodb更新数组$sort操作符
    Mongodb更新数组$pull修饰符
    使用forever运行nodejs应用
  • 原文地址:https://www.cnblogs.com/LBJLAKERS/p/11301892.html
Copyright © 2011-2022 走看看