Was trying out the new QueryOver since Linq doesn't have fetch yet,
but i received a different response than expected.

            var users =
MvcApplication.SessionFactory.GetCurrentSession()
                .QueryOver<User>().Fetch(x=>x.Roles).Eager;

            if (!_userSession.IsUserInRole(UserRoles.Superuser))
                users = users.Where(x => x.Company == user.Company);

            int count =
users.Select(Projections.Count("id")).UniqueResult<int>();

            var pagedUsers = users.OrderBy(x =>
x.LastName).Asc.Skip(page * pageSize).Take(pageSize).List();

to which i receive this error

Column "Users.LastName" is invalid in the ORDER BY clause because it
is not contained in either an aggregate function or the GROUP BY
clause.

Now in linq this runs too queries but it looks like QueryOver doesn't
return the instance, but modifies the existing one. Is this correct?
Do i need to repeat some logic to get the count as well?

Adam

-- 
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