2017-02-25 7 views
1

データをDESC順に並べ替える必要があります。これは私のコードです:ダッパー拡張でDESC順序を使用してOrder by節に従ってデータをソートする方法はありますか?

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拡張機能を使用すると、データを並べ替えることができません。私はDapperの拡張のClassMapperを使用してmyPocoプロパティをマッピングしています

PropertyName was not found for...

:上記のコードは次のようなエラーがスローされます。

答えて

1

Dapper ExtensionのISortを使用してデータを並べ替えることができます。

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; 
    } 
関連する問題