title: Populating entites in Nhibernate
body: <p>can anyone help me with some idea? below is my question.
  Assume that am having a entity named A with fields A1, A2, A3 and A4 and also i have 3 Stored procedures which returns data from table A alone.</p>
  
  <p>(Note: Table A has Only 4 columns A1, A2, A3, A4).</p>
  
  <p>First Stored procedure returning A1, A2
  Second Stored procedure return A1, A2, A3
  Third Stored procedure returns A1 alone .</p>
  
  <p>For the above scenario do i need to create three different mapping or is there any work around?How to handle this scenario with single entity A and with less change code.......</p>
  
  <p><strong>MY SCENARIO:</strong></p>
  
  <pre><code>public IList&lt;Userdatasw&gt; Find(string userName)
          {
              var s = ServiceLocator.Resolve&lt;IeGoatSessionFactory&gt;().OpenSession();
  
              // Executing the stored procedure 
              IList userList1 = s.CreateSQLQuery("exec dbo.IFSEntry @UserName=:UserName")
                  .AddScalar("Password", NHibernateUtil.String)
                  .AddScalar("UserLevel", NHibernateUtil.Int32)
                  .AddScalar("UserName", NHibernateUtil.String)
                  .AddScalar("EmployeeId", NHibernateUtil.String)
                  .AddScalar("SenAccntManager", NHibernateUtil.String)
                  .AddScalar("updaterequired", NHibernateUtil.String)
                  .SetParameter("UserName", userName).List();
  
              // Trying to cast anonymous type to Userdatasw
              IList&lt;Userdatasw&gt; userdatasw1 = userList1.OfType&lt;Userdatasw&gt;().ToList();
              return userdatasw1;
  
          }
  </code></pre>
  
  <p>In the above code the return type is Ilist but i need to convert it to Userdatasw with less changes in code.
  And i have seen many links to explain "populating entites from Stored procedure" in Nhiberante, but i have entity with 20 fields and in the above SP am returning only 6 values.</p>
  
  <p>So for every SP which returns of same type we need to create seperate mapping?</p>
  
  <p>Any idea will be appreciated.</p>
  
  <p>Thanks,
  Venkatesh. J</p>