In my application, I set up triple dictionary matching so that for this user I can get "settings" for each instance of the object owned by the user. That is, I have something like:
public class User
{
public virtual IDictionary<Baz, BazSettings> BazSettings { get; set; }
Therefore, whenever I have an object Baz, I can find the current baz user settings through currentUser.BazSettings[baz].
I would like to be able to use a stateless session for this, but I get LazyInitializationExceptionwith this code:
using (IStatelessSession session = Global.SessionFactory.OpenStatelessSession())
{
var currentUser = session.Get<User>(Membership.GetUser().ProviderUserKey);
var baz = session.Get<Baz>(bazId);
var bazSettings = currentUser.BazSettings[baz];
When I use instead ISession, the problem disappears.
NHibernate "no session session was closed". , . , .
currentUser.BazSettings[baz]?