以下 order by query 出于某种原因不进行任何排序。我这样做正确吗?它只进行选择,根本不应用排序。
var orders = (from order in db.GridExampleTable
select order);
switch (sortBy)
{
default: orders.OrderBy(o => o.UnitPrice);
break;
case "CustomerName":
if (sortDir == "asc")
orders.OrderBy(o => o.CustomerName);
else
orders.OrderByDescending(o => o.CustomerName);
break;
}