title: Is it possible to put NHibernate persistent entities to the same lifetimescope of session?
body: <p>I want to put the persistent entities to the same lifetimescope of the NHibernate session, is it possible?</p>
  
  <pre><code>public class ViewModel
  {
      readonly Func&lt;Owned&lt;ISession&gt;&gt; _sessionFactory;
  
      public ViewModel(Func&lt;Owned&lt;ISession&gt;&gt; sessionFactory)
      {
          _sessionFactory = sessionFactory;
      }
  
      public void DoSomething()
      {
          using (var session = _sessionFactory())
          {
              using (var trans = session.Value.BeginTransaction())
              {
                  session.Value.Get&lt;Model&gt;(1).DoSomething();
                  trans.Commit();
              }
          }
      }
  }
  
  public class Model
  {
      readonly ILifetimeScope _lifetimeScope;
  
      public Model(ILifetimeScope lifetimeScope)
      {
          _lifetimeScope = lifetimeScope;
      }
  
      public void DoSomething()
      {
          ISession session = _lifetimeScope.Resolve&lt;ISession&gt;();
          Model model = session.Get&lt;Model&gt;(2);
          model.Text = "test";
      }
  
      public string Text { get; set; }
  }
  </code></pre>