I have a field that is a string instead of an int, solely because there may be cases like this:
1, 2, 3, 3A, 5, 6 ...
Now, the orderby works fine, in a way, but not as expected:
1
10
11
111
12
2
20
3
Anyone have an idea of doing this? My DB is MySQL. I noticed this solution on other questions..
ORDER BY category_id + 0
How can I implement that in Fluent Nhibernate?
EDIT
To clarify, the required order should be:
1
2
3
3A
10
11
12
20
111
...
EDIT 2
Also take note that it might not only be 3A, it could have more inputs too eg: 3B, 3C.
The order would then be:
1
2
3
3A
3B
3C
10
11
...
You can map this column twice. Once fully for all operations. Once only for “Select” and Ordering.
In XML mapping it would look like this: (the column name is [AsNumber])
The syntax I used is from MS SQL Server. It tries to solve cases like ‘3A‘ above. It will be simply converted to some large value…
Notice that the ‘AsNumber’ has insert and update set to false.
and the C# class snippet:
I’ve tested it and it is working. I am sure that to use similar in fluent won’t take you long…