title: Fluent NHibernate PersistenceSpecification
body: <p>I got the following error message: </p>
  
  <p>System.IndexOutOfRangeException: Invalid index 9 for this SqlParameterCollection with Count=9..</p>
  
  <p>And I absolutely wonder why oO?!</p>
  
  <p>The database schema and the hbm.xml files were all correctly created with FluentNHibernate.
  The error ocurrs in the CanCorrectlyMapBookmethod, the PersistenceSpecificationTest runs without an error.</p>
  
  <pre><code>[TestClass]
  public class PersistenceSpecificationTests
  {
      private static ISession _session;
  
      [TestInitialize]
      public void PersistenceSpecificationTest()
      {
          _session = Helper.CreateSessionFactory(false, false).OpenSession();
      }
  
      [TestMethod]
      public void CanCorrectlyMapBook()
      {
          new PersistenceSpecification&lt;Book&gt;(_session)
              .CheckProperty(p =&gt; p.IncludesCDDVD, true)
              .CheckProperty(p =&gt; p.Isbn, "1232324983sfdsdkfj")
              .CheckProperty(p =&gt; p.Name, "My Book")
              .VerifyTheMappings();
      }
  }
  </code></pre>
  
  <p>The number 9 might come from the amount of columns the book has got. At first I thought I have to check all properties, but I tested this with another enity in another project and it worked correctly.</p>
  
  <p>Anyone has an idea?</p>
  
  <p>edit:</p>
  
  <p>Here my domain object + mapping:</p>
  
  <pre><code>    public interface IEntity
      {
          int Id { get; set; }
      }
  
      public abstract class LoanedItem : IEntity
      {
          public virtual int Id { get; set; }
  
          public virtual DateTime DateOfIssue { get; set; }
  
          public virtual bool IsLoaned { get; set; }
  
          public virtual String Name { get; set; }
  
          public virtual Employee LoanedBy { get; set; }
  
          public virtual Release Release { get; set; }
  
          public virtual Publisher Publisher { get; set; }
  
          public virtual bool IncludesCDDVD { get; set; }
  
      }
  
      public  class Book : LoanedItem
      {
          public virtual string Isbn { get; set; }
  
          public virtual int Author { get; set; }
  
      }
  
   public class BookMap : ClassMap&lt;Book&gt;
      {
          public BookMap()
          {
              // identity mapping
              Id(p =&gt; p.Id).Column("BookID");
  
              // column mapping
              Map(p =&gt; p.Author);
              Map(p =&gt; p.Isbn);
              Map(p =&gt; p.IncludesCDDVD);
              Map(p =&gt; p.IsLoaned);
              Map(p =&gt; p.Name);
  
              // component mapping
              // Publisher
              Component(p =&gt; p.Publisher, m =&gt;
              {
                  m.Map(x =&gt; x.Name);
                  m.Map(x =&gt; x.Homepage);
              });
  
              // Release
              Component(p =&gt; p.Release, m =&gt;
              {
                  m.Map(x =&gt; x.ReleaseDate);
                  m.Map(x =&gt; x.ReleaseNumber);
              });
  
              // reference/association 
              References(p =&gt; p.LoanedBy).Column("EmployeeID");
          }
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Ok the problem above could be solved.</p>
  
  <p>BUT how can I check a component? When I check a component with CheckProperty an error occurs ... "expected 'DomainModel.Model.Book' but get 'DomainModel.Model.Book' ... ugh :) well whats wrong there? it is exactly the same domain object. I created a new <a href="https://stackoverflow.com/questions/1776120/fluent-nhibernate-persistencespecification-issues">question</a></p>