title: How to map a MainValue property using Fluent or LinqToNHibernate?
body: <p>I have a one to many relationship between my product and image entities. What I'm trying to achieve is to map a main image in the product entity, using Fluent mapping or LinqToNHibernate.</p>
  
  <p>My classes:</p>
  
  <pre><code>public class Product {
      public virtual int Id { get; set; }
      public virtual IList&lt;Image&gt; images { get; set; }
  }
  
  public class Image {
      public virtual int Id { get; set; }
      public virtual Product Product { get; set; }
      public virtual bool IsMain { get; set; }
  }
  </code></pre>
  
  <p>My mappings:</p>
  
  <pre><code>public class ProductMap : ClassMap&lt;Product&gt; {
      public ProductMap() {
          Id(x =&gt; x.Id);
          HasMany(x =&gt; x.images).KeyColumn("id_product");
      }
  }
  
  public class ImageClassMap : ClassMap&lt;Image&gt; {
      public ImageClassMap() {
          Table("product_image");
          Id(x =&gt; x.Id);
          References(x =&gt; x.Product, "id_product");
          Map(x =&gt; x.IsMain).Column("is_main");
      }
  }
  </code></pre>
  
  <p>I was able to achieve this with QueryOver as follows:</p>
  
  <pre><code>Image imageAlias = null;
  var product = session.QueryOver&lt;Product&gt;()
      .Where(x =&gt; x.Id == 2)
      .Left.JoinQueryOver(x =&gt; x.images, () =&gt; imageAlias, x =&gt; x.IsMain)
      .SingleOrDefault();
  </code></pre>
  
  <p>Is it possible to have a <code>MainImage</code> property in the <code>Product</code> class, where IsMain property is true, using Fluent mapping or LinqToNHibernate?</p>