NHibernate Queryover选择不同的记录

时间:2013-05-07 11:55:18

标签: nhibernate fluent-nhibernate

我是NHibernate和queryover的新手。我想将nhibernate查询写入以下sql。

SELECT A.*
FROM V_FDS_BANK_MASTR_ADTWORKFL A,
     (SELECT DISTINCT BANK_CD
        FROM V_FDS_BANK_MASTR_ADTWORKFL
        WHERE TRUNC (APPROVEDBY_DATE) BETWEEN TO_DATE ('18/03/2013',
                                                          'DD/MM/YYYY')
                                             AND TO_DATE ('19/03/2013',
                                                          'DD/MM/YYYY')) B
   WHERE A.BANK_CD = B.BANK_CD
ORDER BY A.BANK_CD, APPROVEDBY_DATE

非常感谢

1 个答案:

答案 0 :(得分:0)

var results = Session.QueryOver<A>()
    .WhereRestrictionOn(a => a.ApprovedDate).Between(date1, date2)
    .OrderBy(a => a.BankCD)
        .ThenBy(a => a.ApprovedDate)
    .List()