[英]OrderBy with Linq.Expression
創建排序表達式時遇到問題。
我有一個類型Expression<Func<Products, bool>>
的表達式,該表達式已經包含查詢表達式。 我想進行查詢排序,但未成功。
下面,在CreateSortExpression方法中有一個錯誤:
private Expression<Func<Products, bool>> CreateOrderQuery(Expression<Func<Products, bool>> condition, descriptorOrder item)
{
condition= condition.AndAlso(CreateSortExpression(item.PropertyName));
return condition;
}
private Expression<Func<Products, bool>> CreateSortExpression(string p)
{
Expression<Func<Products, bool>> condition = products =>
p.OrderBy(products.Options.price);
return condition;
}
無法從用法中推斷出錯誤消息“ System.Linq.Enumerable.OrderBy(System.Collections.Generic.IEnumerable,System.Func)”。 嘗試顯式指定類型參數。
有沒有人通過這個可以幫助我? 謝謝。
您正在嘗試構建一個表達式以傳遞給OrderBy()
。
您不想在該表達式中調用OrderBy()
。 你會想要像p => p.Something
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.