score:3
Accepted answer
method syntax
var query = enumerable.orderby(x => x.order == null ? 1 : 0).thenby(x => x.order);
query syntax
var query = from x in enumerable
orderby (x.order == null ? 1 : 0), x.order
select x;
score:0
assuming order is a nullable value (not an object), you should be able to use this:
orderby null == order ? 1 : 0, order
if it is an object, you could try
orderby null == order ? 1 : 0, order.propertyname
Source: stackoverflow.com
Related Query
- How can I translate this SQL Order By statement to LINQ-To-Object?
- C# SQL Statement transformed TO LINQ how can i translate this statement to a working linq
- How do I translate this specifik SQL statement to LINQ
- How do I translate this Sql Statement to Linq
- how can I translate my SQL statement to LINQ
- How can I convert this SQL Query into LINQ (OVER (PARTITION BY Date))
- How do I write this in Ruby/Python? Or, can you translate my LINQ to Ruby/Python?
- How can I use LINQ to project this parent and children object model into a flat, single object?
- How can I achieve SQL CASE statement from LINQ
- How can I combine this code into one or two LINQ queries?
- How can I further simplify this piece of LINQ code
- LINQ - How can I give a child object in a select statement a reference to its parent?
- How to translate this SQL query to a LINQ query in EF Core?
- How can I speed up this linq query on a List<> with search criteria on 3 attributes in the list object
- How do i convert this linq code to inline sql
- This LINQ statement crashes if one of the Properties is NULL. How can I fix this?
- How can I convert this SQL to LINQ
- How can I refactor this code for LINQ filtering?
- How can I convert this SQL to VB.NET LINQ
- linq how would i order this statement
- How can I make a LINQ Select that includes a child object like a SQL outer join?
- How can i make this Linq Statement more sophisticated
- How can I optimise this LINQ query to only execute a single SQL command?
- How can I shorten this linq to sql query?
- How Can I get executable sql statement from linq or IQueryable object?
- How to write the SQL ORDER BY {value} DESC LIMIT statement in LINQ to Entities (Entity Framewok)?
- How can I simplify this LINQ code
- How do I translate this SQL to LINQ
- How can I optimize this LINQ statement for speed?
- How can I avoid repeating some part of the statement in this LINQ
More Query from same tag
- Making sure a value is equal to one of many in LINQ
- Linq: select grouped lists
- Dictionary<> value count c#
- SQL query to linq (with/as, update)
- DataGridView Loading From LINQ
- Linq to sql to get the records from parent-child tables
- How to construct dynamic LINQ query string be for a query that looks like *abc*def*
- convert foreach loop to linq
- Using LINQ to isolate a particular object from a list of objects
- LINQ to Object Basic
- Getting an type conversion error while using linq in entity framework
- ling sql group with join
- Search In claims
- Looking for elegant / efficient solution for integer keyed collection of models
- To remove an item in List
- Tools to convert sql query to linq
- LINQ query problem
- IEnumerable lambda expression for Where()
- Return min/max number in nested list
- LINQ to SQL: Selecting a one-to-many relationship
- How to make menu grow dynamically C#
- EF Core rewrite the query in a form that can be translated after upgrading
- join unknown number of lists in linq
- Slow LINQ Query
- Format LookUp values, retrieved from WebServices
- Entity Framework/LINQ: Selecting columns from multiple tables?
- how to specify literal value in linq union
- How do I check if a SQL Server 2005 TEXT column is not null or empty using LINQ To Entities?
- Why am I getting an InvalidCastException when using an expression from a static field?
- c# - Linq Query to retrieve all objects with a max value