Case When SQL to LINQ

I am still new to LINQ and trying to convert this SQL command

Id     | TitleName
------ | ------
1      | Accounts
2      | Buyer
3      | Engineer
4      | Other
5      | Apple  


SELECT Id, TitleName

    FROM dbo.Title

       ORDER BY 

         CASE WHEN TitleName = 'Other'

            THEN 0 ELSE 1 END DESC, TitleName ASC

This selects the table and ascends it in alphabetical order

  • Saving changes after table edit in SQL Server Management Studio
  • Joining oracle with mssql table
  • How can I sort a table by a numerical string as a number when this sorted columns results contain all numbers in SQL?
  • pass table name as parameter in sql server
  • isolating a sub-string in a string before a symbol in SQL Server 2008
  • Combine fields from joined tables
  • Then it grabs ‘Other’ and forces it to the bottom.

    So it ends up like this

    Id     | TitleName
    ------ | ------
    1      | Accounts
    5      | Apple  
    2      | Buyer
    3      | Engineer
    4      | Other
    

    This works in SQL,
    What is the best approach to achieve this using LINQ ?

    Edit: Issue Resolved

      var queryAllCustomerTitle = from cust in _titleRepository.Table
                                  orderby cust.TitleName == "Other" ? 1 : 0, cust.TitleName
                                  select cust;
    

  • Execute multiple SQL commands in one round trip
  • Why can't I connect to the SQL Server database when I create setup file in Visual studio?
  • Storing and comparing the date and time from SQL Server to .NET when application is used in different time zones
  • nhibernate : saving and retrieving a file to/from database
  • isolating a sub-string in a string before a symbol in SQL Server 2008
  • CASE STATEMENT for create view in SQL Server 2008
  • One Solution collect form web for “Case When SQL to LINQ”

    use the ternary operator

    OrderByDescending(a=>a.TitleName == "Other" ? 0:1).ThenBy(a=>a.TitleName)

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.