title: NHibernate: How to add a List<Product> that i created manually to Nhibernate?
body: <p>I have created a list of products - i.e. List manually in code.</p>
  
  <p>Is it possible with nhibernate to send along a List of Product and have it automatically add the details.</p>
  
  <p>The property on the product class is an automatic increment ID on the database.</p>
  
  <p>I have it defined like so </p>
  
  <pre><code>  public virtual int Id { get; set; }
  </code></pre>
  
  <p>But of course this is a automatic incremental field in the database so what should i set it to on the object (standard c# class) for it to import to the database.</p>
  
  <p>If this is possible.</p>
  
  <p>In my mappings i have it set like so</p>
  
  <pre><code>&lt;class name="Product"&gt;
    &lt;id name="Id" column="ProductID"&gt;
      &lt;generator class="assigned" /&gt;
    &lt;/id&gt;
  &lt;property name="Name" /&gt;
  &lt;more property names are here.............&gt;
  </code></pre>
  
  <p>I think it must be possible but i am having a problem understanding how i can send a collection of my Product model (List) to nhibernate to be inserted automatically</p>
  
  <p>Any help really appreciated</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I would like to clarify what i am doing..  I have the product class which is basically the entity. I have created a number of products which are in a LIST like so List</p>
  
  <p>hence with the collection of products i would like to BATCH insert them into the database.</p>
  
  <p>And clarify that the database's ProductID field is auto generated, hence what do i set the Class' ID to as technically its going to be inserted and the database will take care of this field.</p>
  
  <p>here is my property which represents the ID in the database</p>
  
  <pre><code>  public virtual int Id { get; set; }
  </code></pre>
  
  <p>Maybe i should set it to a nullable INT and then i can set it to NULL?????  Although i am guessing</p>
  
  <p>I hope i have explained myself a little better.</p>