title: Static Method on Domain/Model Object with Repository
body: <p>I have separate repository classes for each entity. Now I would like to implement few static methods on domain object which uses repository instance, but the drawback of this approach is that, I have to hold repository instance on the static variable(which not works well on web application) or I have to create new instance on each static method. Is there any better approach for this(i.e. to implement static method on domain class with repository instance)? please share your ideas.</p>
  
  <p>Base repository:</p>
  
  <pre><code>public abstract class AbstractRepository&lt;TEntity&gt; : IabstractRepository&lt;TEntity&gt;
      where TEntity : EntityObject
  {
      protected CivilRegistryEntities civilContext;
  
      public AbstractRepository()
      {
          civilContext = CivilRegistryEntities.Instance; // Per HTTP request singletone.
      }
  
      // Other method implementation goes here.
  }
  </code></pre>
  
  <p>Per entity repository:</p>
  
  <pre><code>public class BirthReportRepository : AbstractRepository&lt;BirthReport&gt;
  {
  
  }
  </code></pre>
  
  <p>Domain/Entity/Model object:</p>
  
  <pre><code>public partial class BirthReport
  {
      //Not works well in web application.
      private static BirthReportRepository repository = new BirthReportRepository();
  
      public static BirthReport Method1()
      {
          return repository.SomeMethod();
      }
  
      public static BirthReport Method2()
      {
          return repository.SomeOtherMethod();
      }
  
      // Other methods(both static and instance) goes here.
  }
  </code></pre>