tags:

views:

173

answers:

0

In one of my queries I have to order the result by a defined order. It looks like this:

    public IList<Media> CollectionFor(int[] uidArray)
    {
            Sess.CreateQuery("... where m.Uid in (:uidList) order by FIND_IN_SET(m.Uid, '" + Misc.JoinNumberArray(uidArray) + "')")
            .SetParameterList("uidList", uidArray)
    }

Pretty ugly and probably not really safe.

I would rather write it like so:

    public IList<Media> CollectionFor(int[] uidArray)
    {
            Sess.CreateQuery("... where m.Uid in (:uidList) order by FIND_IN_SET(m.Uid, \":uidList\")")
            .SetParameterList("uidList", uidArray)
    }

But that does not work. A NHibernate Exception is the result.

Is it still possible?