title: FluentNHibernate Overrides: UseOverridesFromAssemblyOf non-generic version
body: <p>I have a repository class that inherits from a generic implementation:</p>
  
  <pre><code>public namespace RepositoryImplementation {
      public class PersonRepository : Web.Generics.GenericNHibernateRepository&lt;Person&gt;
  }
  </code></pre>
  
  <p>The generic repository implementation uses Fluent NHibernate conventions. They're working fine. One of those conventions is that all properties are not nullable.</p>
  
  <p>Now I need to define that specific properties may be nullable outside the conventions. Fluent NHibernate has an interesting override mechanism:</p>
  
  <pre><code>public namespace RepositoryImplementation {
      public class PersonMappingOverride : IAutoMappingOverride&lt;Person&gt; {
          public void Override(FluentNHibernate.Automapping.AutoMapping&lt;Funcionario&gt; mapping)
          {
              mapping.Map(x =&gt; x.PhoneNumber).Nullable();
          }
      }
  }
  </code></pre>
  
  <p>Now I need to register the override class into Fluent NHibernate. I have the following code in the <code>Web.Generics.GenericNHibernateRepository</code> generic class:</p>
  
  <pre><code>AutoMap.AssemblyOf&lt;Person&gt;()
    .Where(type =&gt; type.Namespace == "Entities")
    .UseOverridesFromAssemblyOf&lt;PersonMappingOverride&gt;();
  </code></pre>
  
  <p>The problem is: <code>UseOverridesFromAssemblyOf</code> is a generic method, and I can't do something like that:</p>
  
  <pre><code>.UseOverridesFromAssemblyOf&lt;PersonMappingOverride&gt;();
  </code></pre>
  
  <p>Because that would cause a circular reference. I don't want the generic repository to know the either repository or the mapping override class, because they vary from project to project.</p>
  
  <p>I see another solution: in the GenericNHibernateRepository class I can do this.GetType() and get the repository implementation type (e.g.: PersonRepository). However I can't call <code>UseOverridesFromAssemblyOf()</code> passing a type.</p>
  
  <p>Is there another way to configure overrides in FluentNHibernate? If not, how could I call <code>UseOverridesFromAssemblyOf&lt;T&gt;</code> without making the generic repository depend upon the repository implementation or the mapping override class?</p>
  
  <p>(Source: <a href="http://wiki.fluentnhibernate.org/Auto_mapping#Overrides" rel="nofollow noreferrer">http://wiki.fluentnhibernate.org/Auto_mapping#Overrides</a>)</p>