Order by descending based on condition?

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().

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().

You could reduce it a step further with var hosters = from e in context. Hosters_HostingProviderDetail where e. ActiveStatusID == pendingStateId select e; if (sortOrder == SortOrder.

ASC) hosters = hosters. OrderBy(e => e. HostingProviderName); else hosters = hosters.

OrderByDescending(e => e. HostingProviderName); return hosters.ToList().

Hosters = (sortOrder == SortOrder. OrderBy(e => e. HostingProviderName) : hosters.

OrderByDescending(e => e. ReturnList = hosters. Var hosters = from e in context.

If (sortOrder == SortOrder. Hosters = hosters. OrderBy(e => e.

Hosters = hosters. OrderByDescending(e => e. Not the answer you're looking for?

Or ask your own question.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions