Please help, Can I do this in query over nhibernate?
select max(Id) from transTable
group by PortfolioId.
I've tried this.
var subquery = QueryOver.Of(() => q)
.SelectList(list => list.SelectGroup(() => q.PortfolioId))
.Where(Restrictions.EqProperty(
Projections.Property(() => p.Id),
Projections.Max(() => q.Id)))
.And(Restrictions.EqProperty(
Projections.Property(() => p.Id),
Projections.Property(() => q.Id)));
and then
var filter = QueryOver.Of(() => p)
.WithSubquery.WhereExists(subquery)
.Select(Projections.Property(()=>p.Id));
but it doesn't work. it returns all data from the table. I just wanna get the last sequenceIDs from every user.
please help. Thanks