NHibernate difference between Query, Get and Load

前端 未结 2 947
遥遥无期
遥遥无期 2020-12-21 09:57

I\'d like to find the difference in using these three ways of getting data from the database when doing something like:

public T GetById(int id) {
    using          


        
2条回答
  •  离开以前
    2020-12-21 10:14

    how the Query() differs from QueryOver()?

    QueryOver is a strongly-typed version of Criteria, and is more NHibernate specific. Pretty much anything you can do in ICriteria can be done with QueryOver. In the golden days of ICriteria NH2 you always had to cast, hence this is why now you need to cast at the end of the chain back to an int.

    LINQ (Query) is a standard query method that works on IQueryable that doesn't need explicit references to NHibernate and can be considered more ORM agnostic and therefore follows the linq standard. As you rightly pointed out you do not need to cast to an int as your are selecting into the result the customNumber.

提交回复
热议问题