• .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

  • 相关阅读:
    (Problem 14)Longest Collatz sequence
    (Problem 13)Large sum
    (Problem 10)Summation of primes
    (Problem 9)Special Pythagorean triplet
    (Problem 7)10001st prime
    (Problem 6)Sum square difference
    数组
    断点及复习
    抽象和封装
    类和对象
  • 原文地址:https://www.cnblogs.com/LBJLAKERS/p/11301892.html
Copyright © 2020-2023  润新知