The essential situation is that I have a table "blah" that is mapped
to a Blah domain object by NHibernate (I've just made up the table
name etc. here). I want to perform a paginated search on the "blah"
table, and provide a custom ordering on one of its fields - i.e. the
SQL that I eventually want to be executed is something like:
select top 10 * from blah
where <search_criteria>
order by
case orderCol
when 0 then 1
when 1 then 0
when 2 then 3
when 3 then 2
else 4
end
(in this example the ordering is something completely artificial).
The C# code I'm executing is something like:
ISession.Linq<Blah>().Where(<search_criteria>).OrderBy(x =>
x.OrderCol, new CustomComparer())
where the CustomComparer() class implements my custom ordering
behaviour. However, when I monitor the SQL that NHibernate generates,
I just see something like:
select top 10 * from blah
where <search_criteria>
order by orderCol asc
(i.e my Comparer appears to be ignored - perhaps not too surprising).
My question is whether a custom ordering like this is even possible
using NHibernate?
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
Owen
On Apr 2, 7:20 pm, Diego Mijelshon <di...@mijelshon.com.ar> wrote:
> Create a property mapping on that case expression and use it for sorting.
> Example: <property name="WeirdSortingProperty" formula="case orderCol ..."
> />
>
> Diego
>
> > nhusers+u...@googlegroups.com<nhusers%2Bunsu...@googlegroups.com>