Lazy Loading in NHibernate

前端 未结 5 1044
不知归路
不知归路 2021-01-19 10:47

If a Customer has many Orders attached to them. How would you lazy load the Orders List using NHibernate.

Is it something that needs to be set up mapping file? any

5条回答
  •  暖寄归人
    2021-01-19 10:55

    Chris' suggestion is how I'd do it, however if you want to do it at runtime you can set the Fetchmode on your criteria to be lazy like so:

    criteria.SetFetchMode("Orders", FetchMode.Lazy)
    

提交回复
热议问题