2

我想按 DESC 顺序对数据进行排序。这是我的代码:

var predicate = Predicates.Sort<myPoco>(x => x.name, false);
var result = GetList<myPoco>(predicate).ToList();

protected IEnumerable<T> GetList<T>(object predicate, IList<ISort> sort = null, IDbTransaction transaction = null, int? commandTimeout = null, bool buffered = false) where T : class
{
    var result = connection.GetList<T>(predicate, sort, transaction, commandTimeout, buffered);
    return 
}

使用 Dapper Extensions,我无法对数据进行排序。上面的代码抛出以下错误:

未找到 PropertyName...

我正在myPoco使用 Dapper Extension 的ClassMapper.

4

1 回答 1

4

ISort您可以使用Dapper Extension对数据进行排序。

List<ISort> sortList = new List<ISort>();
sortList.Add(Predicates.Sort<myPoco>(x => x.Name, false));

var result = GetList<myPoco>(null, sortList).ToList();
 return result;

    protected IEnumerable<T> GetList<T>(object predicate, IList<ISort> sort = null, IDbTransaction transaction = null, int? commandTimeout = null, bool buffered = false) where T : class
     {
                    var result = connection.GetList<T>(predicate, sort, transaction, commandTimeout, buffered);
                    return result;
     }
于 2017-02-27T11:11:39.223 回答