Descending order does not work with LINQ to Entity

Descending order doesn't work with LINQ to Entity In the next query Instead of ascending If I keep going down it doesn't work. Please help me

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

return hosters.ToList();

      

+2


a source to share


2 answers


This should return the correct result. It works great for me.



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

return hosters.ToList();

      

+4


a source


You can also use a lambda expression to get the same result:



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

      

+4


a source







All Articles