title: Nhibernate - mapping generic IList objects to comma separated lists of Keys in single DB column
body: <p>I may be trying to be too ambitious here but I'm hoping someone might be able to suggest a solution.</p>
  
  <p>I have a number of UserChoice objects, such as TravellingChoices, SocialisingChoices, SportChoices etc and in a users profile, each user specifies exactly which one they fall under, so in the DB they have a single profile row mapped with INT ids corresponding to the keys of the choice options they have chosen.</p>
  
  <p>When you load the profile up with NHibernate, I use many-to-one mappings to build up a profile object which actually contains the TravellingChoice, SocialisingChoice, SportChoice etc objects themselves, not the id's, which is what I want.</p>
  
  <p>The problem is I then want people to be able to search for other users who fit certain criteria, but you are allowed to select multiple ones. Eg users with either one of two different travelling choices, or you can choose 3 sport choices to search on.</p>
  
  <p>So the search criteria object I wanted to have in memory as a number of strongly typed lists eg</p>
  
  <pre><code>IList&lt;TravellingChoice&gt;
  IList&lt;SocialisingChoice&gt;
  </code></pre>
  
  <p>and so forth.</p>
  
  <p>The problem is I am storing the search criteria object in db as a number of columns with id separated lists
  eg</p>
  
  <pre><code>SocialisingChoicesColumn : 1,2,6
  TravellingChoicesColumn : 5,8
  </code></pre>
  
  <p>etc..</p>
  
  <p>What I want to be able to do is have an nhibernate mapping take my table with columns full if id/comma lists, and translate each one into the relevant Typed Ilist with fully populated objects.</p>
  
  <p>So how do I go from the above table with id/comma lists, to an object with</p>
  
  <pre><code>IList&lt;TravellingChoice&gt;
  IList&lt;SocialisingChoice&gt;
  </code></pre>
  
  <p>etc..
  properties?</p>
  
  <p>Is this possible or too complex for Nhibernate?</p>