title: nHibernate SQL Not Available error
body: <p>I have the following code to execute a simple select statement.
  This query fails given the "SQL Not Available" error.
  This same code as a pattern works just fine in about 20 different models.
  In fact if I alter the design of the view implemented in SQL to say hide the LoadID column the query fails stating "Can execute ...  ... because LoadID doesn't exist.</p>
  
  <p>My problem is when this code, the hbm.xml model, and the design of the view are all aligned the ses.Query() fails stating "SQL not available"</p>
  
  <pre><code>var rows = ses.Query&lt;vInventory&gt;().Where(c =&gt; c.CustomerRecid == recid).Select(c =&gt; new vInventory()
  {
      InventoryRecid = c.InventoryRecid
      , ItemID = c.ItemID
      , LoadID = c.LoadID
      , CustomerRecid = c.CustomerRecid
  }).ToList();
  </code></pre>
  
  <p>This is the mapping.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true" assembly="Asmbly" namespace="Asmbly.Models"&gt;
    &lt;class name ="vInventory" table="dbo.vInventory" dynamic-update="true"&gt;
      &lt;cache usage="read-only"/&gt;
      &lt;id name="InventoryRecid" column="InventoryRecid" type="Int64"&gt;
        &lt;generator class="native" /&gt;
      &lt;/id&gt;
      &lt;property name="ItemID" /&gt;
      &lt;property name="LoadID" /&gt;
      &lt;property name="CustomerRecid" /&gt;
    &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>Update.  I took the output of the SQL view and dumped it into a table.
  Then modified the hbm.xlm to point to the table.
  Now the ses.Query() works fine.  This is NOT a workable possibility.</p>
  
  <p>Please comment on InventoryRecid.  In the SQL view this attribute is </p>
  
  <p><code>ROW_NUMBER() over (...)</code></p>
  
  <p>How can I get nHibernate to use this view and utilize the InventoryRecid attribute?
  I will never have attempt an update to this entity.</p>
  
  <p>Update #2:
  I changed the hbm.xlm mapping from</p>
  
  <pre><code>&lt;class name ="vInventory" table="dbo.vInventory" dynamic-update="true"&gt;
  </code></pre>
  
  <p>to</p>
  
  <pre><code>&lt;class name ="vInventory" table="dbo.vInventory" dynamic-update="false"&gt;
  </code></pre>
  
  <p>recompiled and my problem is gone.</p>
  
  <p>Unfortunately, I change it back to true and recompile and my problem doesn't come back.</p>