qtvb1987 2019-08-30 15:36 采纳率: 12.5%
浏览 248

jqgrid linq 分页查询问题

比如我SortCode 字段为null 排序,返回数据总数对的,但是分页数据显示会有重复行,换个其他字段就分页数据显示就对的,不知道啥问题。

不像sql rownumber函数 order by 字段必需唯一不重复

jqgrid 前台页面通过 sortname: 'SortCode', sortorder: 'asc',

字段传到后台排序

底层方法
public IEnumerable FindList(Expression> condition, string orderField, bool isAsc, int pageSize, int pageIndex, out int total) where T : class,new()
{
using (var dbConnection = Connection)
{
string[] _orderField = orderField.Split(',');
var dataLinq = new SQLinq().Where(condition);

            foreach (string item in _orderField)
            {
                var parameter = Expression.Parameter(typeof(T), "t");
                var property = typeof(T).GetProperty(item);
                var propertyAccess = Expression.MakeMemberAccess(parameter, property);
                Expression<Func<T, object>> orderBy = t => propertyAccess;
                dataLinq.OrderByExpressions.Add(new SQLinq<T>.OrderByExpression { Ascending = isAsc, Expression = orderBy });
            }
            var dataQuery = dbConnection.Query<T>(dataLinq);
            total = dataQuery.Count();
            var data = dataQuery.Skip<T>(pageSize * (pageIndex - 1)).Take<T>(pageSize).AsQueryable();
            return data.ToList();
        }
    }
  • 写回答

1条回答 默认 最新

  • threenewbee 2019-08-30 16:33
    关注

    排序的字段本身是否有重复,将
    dataLinq = new SQLinq().Where(condition);
    写成dataLinq = new SQLinq().Where(condition).AsEnumerable();
    看看是不是可以

    评论

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制