LINQ to Entity不按降序排序

时间:2010-04-15 10:05:37

标签: c# asp.net linq entity-framework linq-to-entities

降序排序不适用于LINQ to Entity 在下面的查询代替升序如果我继续下降它不起作用。请帮帮我

var hosters =
    from e in context.Hosters_HostingProviderDetail
    where e.ActiveStatusID == pendingStateId
    orderby e.HostingProviderName ascending
    select e;

return hosters.ToList();

2 个答案:

答案 0 :(得分:4)

答案 1 :(得分:4)

您还可以使用lambda表达式来获得相同的结果:

return context.Hosters_HostingProviderDetail.Where(e => e.ActiveStatusID == pendingStateID).OrderByDescending(e => e.HostingProviderName).ToList();