How can I convert the query from SQL to LINQ?

Can anyone convert this SQL query to linq query ----select *from xxxxxxxxxxxxxxxxx order by case when a=5 then a end desc, case when b=10 then b end desc

  • Answer:

    Can you try the below query : var q = from table in xxxxxxxxxxxxxxxxx             select table; if(a==5)  q = q.OrderByDescending(t=>t.a) if(b==10)  q = q.OrderByDescending(t=>t.b)

Dharmendra Kumar at Quora Visit the source

Was this solution helpful to you?

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.