What is the difference between NHibernate Query<> vs QueryOver<>?

后端 未结 2 819
生来不讨喜
生来不讨喜 2020-12-29 19:54

I just started with NHibernate (using SQLite) in my current project and I mostly used Query<>, because I was familiar writing db queries in Linq.

2条回答
  •  再見小時候
    2020-12-29 20:15

    About your QueryOver version, I would have written :

    int result = Session.QueryOver()
                   .Select(Projections.Max(x => x.CustomNumber))
                   .SingleOrDefault();
    

    It seems quite readable, and the resulting SQL would be something like :

    SELECT max(this_.CustomNumber) as y0_ FROM "BillingDataEntity" this_
    

    Hope this will help

提交回复
热议问题