I don't think you can put a condition into the larger query, but what you could do is separate it into another C# statement, like this:// Common code:var hosters = from e in context.Hosters_HostingProviderDetail where e.ActiveStatusID == pendingStateId;// The difference between ASC and DESC:hosters = (sortOrder == SortOrder.ASC ? hosters.OrderBy(e => e.HostingProviderName) : hosters.OrderByDescending(e => e.HostingProviderName));// More common code:returnList = hosters.ToList<Hosters_HostingProviderDetail>(); 这篇关于根据条件降序排列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-16 05:01