title: Fluent NHibernate ignore property inside the ClassMap, using FluentMappings
body: <p>I am using NHibernate 3.1 and Fluent NHibernate as ORM in my project. I need to have a property of a POCO ignored by Fluent NHibernate. At first, my post might look as exact duplicate of <a href="https://stackoverflow.com/questions/907576/how-to-tell-fluent-nhibernate-not-to-map-a-class-property">this question</a>, but it is not. </p>
  
  <p>My complications come first from the fact that the POCOs are defined in a different assembly than the mapping and I am using <strong>fluent mappings</strong> for my POCOs. I have additional requirement not to write ingore-property code where the session factory configuration takes place (this happens at a centralized place outside the modules), but as part of the module that defines the mappings. Ideally, I believe the right place would be the concrete <code>ClassMap</code> implementation, since it knows exactly how to describe a POCO to the ORM.</p>
  
  <p>However, I am stuck on this mainly because this is my first impact with NHibernate and its fluent API. Up to now I am having very good impression of its capabilities and extensibility, and I hope there is a way to achieve my requirement in a way that the mapping related code is encapsulated in its corresponding module.</p>
  
  <p>Here is my configuration, from a centralized place:</p>
  
  <pre><code>List&lt;Assembly&gt; assemblies = GetModules().Select(x =&gt; x.GetType().Assembly).ToList();
  
  ISessionFactory nhibernateSessionFactory = Fluently
      .Configure()
      .Mappings(m =&gt; assemblies.ForEach(asm =&gt; m.FluentMappings.AddFromAssembly(asm)))
      .Database(
          MsSqlConfiguration.MsSql2005
              .ShowSql()
              .ConnectionString(DatabaseConfig.Instance.ConnectionString))
      .ExposeConfiguration(c =&gt; new SchemaUpdate(c).Execute(true, true))
      .BuildSessionFactory();
  </code></pre>
  
  <p>I use standard class mappings that inherit from <code>ClassMap</code>:</p>
  
  <pre><code>public class User
  {
      public virtual int ID { get; set; }
      public virtual String Username { get; set; }
      public virtual String Password { get; set; }
      public virtual DateTime DateCreated { get; set; }
      public virtual DateTime DateModified { get; set; }
  
      // Must ignore
      public string ComputedProperty  { get { ... } }
  }
  
  public class UserMap : ClassMap&lt;User&gt;
  {
      public UserMap()
      {
          Table("User");
          Id(x =&gt; x.ID).GeneratedBy.Identity();
          Map(m =&gt; m.Username).Not.Nullable().Length(255).UniqueKey("User_Username_Unique_Key");
          Map(m =&gt; m.Password).Not.Nullable().Length(255);
          Map(m =&gt; m.DateCreated).Not.Nullable();
          Map(m =&gt; m.DateModified).Not.Nullable();
      }
  }
  </code></pre>