I'm refactoring old-style query CreateCriteria()
to QueryOver()
. My Wcf service gets string PropertyName
to order queries results. For IQueryable
I use Dynamic LINQ to do such ordering, for CreateCriteria()
- AddOrder()
.
IList<object[]> result =
GetSession()
.QueryOver(() => activity)
.JoinAlias(() => activity.ActivityLicense, () => license)
.Select(Projections.ProjectionList()
.Add(Projections.Count<Activity>(e => e.Id), "ActivityCount")
.Add(Projections.Group(() => license.SerialNumber), "SerialNumber")
.Add(Projections.Count<Activity>(e => e.MacAdress), "MacAddressCount")
.Add(Projections.Count<Activity>(e => e.IpAdress), "IpAddressCount")
)
.OrderByAlias("ActivityCount") // Compilation Error - I need such extension method
.List<object[]>();
Any suggestions how to do ordering in case with string property names?
PS: I could not use LINQ to Nhibernate: LINQ to NHibernate - .GroupBy().Skip().Take() cause an exception
Thanks!