I want to match an SQL query Business objectwith using Nhibernate. There are many fields in the Employee table, but I get only three and want them to display only those.
here is my sql query
<sql-query name="findEmployeesInfo">
<return alias="emp" class="Calibr.BusinessDocuments.BOs.Employee, BusinessDocuments"/>
<![CDATA[
select (emp.Eid) as {emp.Id},(emp.FirstName) as {emp.FirstName},(emp.LastName) as {emp.LastName} from Employee emp
]]>
</sql-query>
here I am creating a constructor to display these columns
public Employee(int Id, string FirstName, string LastName)
{
this.Id = Id;
this.FirstName = FirstName;
this.LastName = LastName;
}
DB Employee Table Column Names: Eid, FirstName, LastName, ............
I get this exception
failed to execute the request [select (emp.Eid) as Eid1_0 _, (emp.FirstName) as FirstName1_0 _, (emp.LastName) as LastName1_0_ from Employee emp
Edit: if I select all columns, it will work perfectly -Select * from Employee emp
Thank you for your help.
source
share