比如我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();
}
}