title: Fluent NHibernate Mapping Single Column to Composite Key
body: <p>I have a situation where i have defined an entity in my domain model in which I would like to expose a single id column.</p>
  
  <pre><code>public class OfferedProduct  
  {  
      public virtual string Id {get; set;}  
  
      //other properties
  }
  </code></pre>
  
  <p>The legacy database table this will map to is</p>
  
  <pre><code>CREATE TABLE ProductGrouping  
  MemberNumber INT NOT NULL,
  GroupId CHAR NOT NULL,
  ...
  </code></pre>
  
  <p>I dont want to compromise the domain model by introducing two properties and mapping them using the "CompositeId" construct.</p>
  
  <pre><code>CompositeId().KeyProperty(x =&gt; x.MemberNumber).KeyProperty(x =&gt; x.GroupId)
  </code></pre>
  
  <p>What I want ideally is to concatenate the two values in the form {MemberNumber}{GroupId} and expose this as the Id value. I would then use a Custom Type to handle how these values are concatenated when retrieved from the DB and broken apart when saving/selecting.</p>
  
  <p>I have noticed that the "CompositeId" method does not allow a customType as with the standard "Id" call; but the "Id" method does not provide the ability to set multiple columns. I have seen examples where people have used "Map" to combine two columns using a custom type, but not for id values.</p>
  
  <p>I have noticed the "CompositeId" has an overload that can take a custom identity class but I am unsure how to use it in this scenario.</p>
  
  <pre><code> CompositeId&lt;OfferedProductIdentifier&gt;(x =&gt; x.?)
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>