Как выполнить этот запрос в NHibernate, с критериями или QueryOver
?
select r.relationshipidentifier, r.publicrelationshipid
from relationship r
inner join (
select max(asofdate) as asofdate, s.relationshipidentifier
from relationship s
group by s.relationshipidentifier
) m
on r.asofdate = m.asofdate and r.relationshipidentifier = m.relationshipidentifier
Предположим,
public class Relationship {
public virtual Guid Id { get; set; }
public virtual DateTime AsOfDate { get; set; }
public virtual Guid RelationshipIdentifier { get; set; }
public virtual Guid PublicRelationshpId { get; set; }
}