I've got a hibernate query that returns a list of objects and I want to order by a title. This is a user maintained field and some of our customers like prefixing their titles with numbers, this isn't something I can control. The data is something like this:
- 1 first thing
- 2 second thing
- 5 fifth thing
- 10 tenth thing
- 20 twentieth thing
- A thing with no number
A traditional
.AddOrder(Order.Asc("Name"))
Is resulting in a textual sort:
- 1 first thing
- 10 tenth thing
- 2 second thing
- 20 twentieth thing
- 5 fifth thing
- A thing with no number
This is correct as this is a nvarchar field but is there any way I can get the numbers to sort as well?
There seem to be several workarounds involving prefixing all fields with leading 0's and such like but do any of these work through NHibernate?
This application runs interchangeably on Oracle and MsSQL.
Cheers,
Matt