Reputation: 9611
Say I have a query like:
return NHibernateHelper.Session.QueryOver<SomeEntity>()
.JoinQueryOver(x => x.Entity2)
.JoinQueryOver(x => x.Entity3)
.Where(x = x.Id > 10)
.OrderBy( ???? )
.List<SomeEntity>();
Now say I want to order by Entity3.SortOrder column, how can I do that?
Upvotes: 2
Views: 1255
Reputation: 79929
Entity2 e2Alias = null;
Entity3 e3Alias = null;
SomeEntity s = null;
return NHibernateHelper.Session.QueryOver<SomeEntity>()
.JoinAlias(() => s, () => e2Alias.SomeEntityReference) //here you need to specify the other side of the relation in the other entity that refernces th SomeEntity
.JoinAlias(() => s, () => e3Alias.SomeEntityReference)
.Where(() => s.Id > 10)
.OrderBy( () => e3Alias.SortOrder).Asc //or Desc
.List<SomeEntity>();
Upvotes: 3