Hello everyone,

I cannot use the OrderByAlias / ThenByAlias method in QueryOver query.
When I use
this.Session.QueryOver<Product>()
                .OrderBy(x => x.Name).Desc
                .JoinQueryOver(x => x.Category, () => categoryAlias)
                .OrderBy(x => x.Name).Asc
                .List<Product>();

It produces the right SQL:
SELECT   this_.ProductId           as ProductId6_1_,
         this_.ProductName         as ProductN2_6_1_,
       ...
         categoryal1_.Description  as Descript3_5_0_
       ...
FROM     Products this_
         inner join Categories categoryal1_
           on this_.CategoryId = categoryal1_.CategoryId
ORDER BY this_.ProductName desc,
         categoryal1_.CategoryName asc

But when I try to write this query in other way - like this:
 this.Session.QueryOver<Product>()
                .JoinAlias(x => x.Category, () => categoryAlias)
                .OrderBy(x => x.Name).Desc
                .ThenByAlias(() => categoryAlias.Name).Asc
                //.OrderByAlias(() => categoryAlias.Name).Asc
                .List<Product>();

it produces wrong SQL (insted of category name it orders ascending by
product name ):
SELECT ... FROM Products this_ inner join Categories categoryal1_ on
this_.CategoryId=categoryal1_.CategoryId ORDER BY this_.ProductName
desc, this_.ProductName asc

Did I missed something ?

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to