Delay initialization in .NET – NHIBERNATE

If the relationship between one entity and another entity is mapped as Lazy = False, but for a certain function I need to get them in Lazily, is it possible to do it at runtime?
No, you can’t. As the commenter pointed out, you can map it to lazily and eagerly, But not the other way around.

That is, in LINQ, you can use Fetch / FetchMany / ThenFetch / ThenFetchMany to get the relationship eagerly:

session. Query()
.Where(x => x.Name == "Ruba")
.FetchMany(x => x.Children)
.ThenFetch(x => x .SomethingMore);

If the relationship between one entity and another entity is mapped as Lazy = False, but for a certain function I need to get them in Lazily, it may be in Does it happen at runtime?

No, you can’t. As the commenter pointed out, you can map it to lazily and eagerly, but not the other way around.

< p>That is, in LINQ, you can use Fetch / FetchMany / ThenFetch / ThenFetchMany to get the relationship eagerly:

session.Query()
.Where (x => x.Name == "Ruba")
.FetchMany(x => x.Children)
.ThenFetch(x => x.SomethingMore);

Leave a Comment

Your email address will not be published.