title: Avoiding logic in setter properties when using NHibernate
body: <p>I have a design like this:</p>
  
  <pre><code>public class Employee {
      //...
  }
  
  public class Company {
      private IList&lt;Employee&gt; _employees;
  
      public IList&lt;Employee&gt; Employees {
          get { return _employees; }
          set {
              if (_employees == value) {
                  return;
              }
  
              _employees = value;
  
              //Some logic here. Eg:
              //Raise PropertyChanged
              //Iterate over the new values to suscribe to some events, etc.
          }
      }
  }
  </code></pre>
  
  <p>when I try to do something like:</p>
  
  <pre><code>var employees = session.Query&lt;Company&gt;().Fetch(x =&gt; x.Employees).ToList();
  </code></pre>
  
  <p>it throws a <code>LazyInitializationException</code>:</p>
  
  <blockquote>
    <p>illegal access to loading collection</p>
  </blockquote>
  
  <p>The only workaround I've found is moving the logic to a method, making this method public (and virtual) and calling the method for every instance in <code>employees</code>, but I don't like that since I will be calling that method from my repositories.</p>
  
  <p>Any ideas?</p>