edit
I’m a fool and had a typo in my controller, it’s all good now. (it’s been a very long week)
Ok, this is something i’m not sure of. I’m thinking about implementing what i want in a different way but I want to find out if there’s a way to do this.
I have an IQueryable object and in my table, i have a column of type bool and wish to order it by true/false in a table.
Here’s something along the lines of what I’ve tried:
mQueryableObject.OrderBy(model => model.myBoolean);
this doesn’t give me the expected result, as I would half expect.
So is there any way to order an IQueryable object (LINQ) by boolean value (true/false).
I’d really appreciate some insight.
Well without knowing what you expect, it’s hard to know what’s wrong here. It’s also not clear whether you’ve really got that
OrderBycall as a statement by itself. If so, that’s the problem – LINQ operators don’t mutate an existing query; they return a new query. For example, this may be all you need:This will sort
falsebeforetrue, by the way. If you want it the other way round, just use: