有什么方法可以编写集成测试来测试 FetchMode.Eager 是否正常工作?当我检索 MySubObject 时,我想验证它不会进入数据库。
代码:
public MyObject GetEager(string name)
{
return Session
.CreateCriteria(typeof(MyObject))
.SetFetchMode("MySubObject", FetchMode.Eager)
.Add(Restrictions.Eq("Name", name))
.UniqueResult<MyObject>();
}
最佳答案
您还可以使用 NHibernateUtil.IsInitialized
... 如本文所述
http://nhibernate.info/doc/howto/various/lazy-loading-eager-loading.html
关于c# - 如何正确测试 NHibernate FetchMode.Eager?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1015001/