nhibernate - disable automatic\lazy loading of child records for one to many relationsihps

后端 未结 2 1761
误落风尘
误落风尘 2021-02-08 11:38

I would like to know if there is a way to disable automatic loading of child records in nHibernate ( for one:many relationships ).

We can easily switch off lazy loading

2条回答
  •  长发绾君心
    2021-02-08 12:11

    You can have the lazy attribute on the collection. In your example, Department has n employees, if lazy is enabled, the employees will not be loaded by default when you load a department : http://www.nhforge.org/doc/nh/en/#collections-lazy

    You can have queries that explicitly load department AND employees together. It's the "fetch" option : http://www.nhforge.org/doc/nh/en/#performance-fetching-lazy

提交回复
热议问题