c# Subsonic 2.1 : Order by case

I would like to know if its possible to order by a specific ID in subsonic 2.1. Same as regular sql query:

WHEN ID = 5 then 1 
WHEN ID = 10 then 2 
WHEN ID = 1 then 3 
WHEN ID = then 4 
else 5 

I hope someone can help me, I want this functionality for country specific content.

Kind regards, Mark


You can do the following:

Dim q As SubSonic.SqlQuery =
    New SubSonic.Select().From(MyTable.Schema)
    .OrderAsc("case when ID = 5 then 1 when ID = 10 then 2 else 5 end")
Dim foo = q.ExecuteAsCollection(Of MyTableCollection)()

I don't think there is any SubSonic native, type-safe syntax (i.e. Case().When()...), but this works.

Need Your Help

Variable Issues

java variables

So this project requires me to "make up" a secret agent, and by doing this by randomized events- like birthday, gender, name, city etc... I've been having trouble with my birthday portion of this

custom font in Android Studio

android fonts android-typeface

How to create custom fonts in android studio ?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.