In the context of my example project, I have a Post table and a Comment table. A Post has a one-to-many relationship with Comment. The PostMap is configured to use CollectionLazy.NoLazy for Comments.
I wrote four unit tests in the attached project to demonstrate an issue. I use Future/FutureValue to get Posts/Post, and I expected the related child Comments to be loaded and usable outside the session. However, it throws a LazyInitializationException.
I then tried another approach using QueryOver.List (which returns a list of entities) or QueryOver.SingleOrDefault, and in this case, I can use the Comments as expected.
Is this the expected behavior of Future/FutureValue or is it a bug?
Please see the attached file for a reproducible project (also includes database script, and unit test) FutureDoesNotLoadNoLazyChildNHibernate.zip
Steps to reproduce:
In the context of my example project, I have a
Post
table and aComment
table. APost
has aone-to-many
relationship withComment
. ThePostMap
is configured to useCollectionLazy.NoLazy
for Comments.I wrote four unit tests in the attached project to demonstrate an issue. I use
Future
/FutureValue
to get Posts/Post, and I expected the related childComments
to be loaded and usable outside the session. However, it throws a LazyInitializationException.I then tried another approach using
QueryOver.List
(which returns a list of entities) orQueryOver.SingleOrDefault
, and in this case, I can use theComments
as expected.Is this the expected behavior of
Future
/FutureValue
or is it a bug?Please help me check. Thanks in advance.