I have following tables
Employee: ID,CompanyID,Name //CompanyID is foriegn key of Company Table
Company: CompanyID, Name
I want to map this to the following class:
public class Employee
{
public virtual Int ID { get; set; }
public virtual Int CompanyID { get; set; }
public virtual string Name { get; set; }
public virtual string CompanyName { get; set; }
protected Employee() { }
}
here is my xml class
<class name="Employee" table="Employee" lazy="true">
<id name="Id" type="Int32" column="Id">
<generator class="native" />
</id>
<property name="CompanyID" column="CompanyID" type="Int32" not-null="false"/>
<property name="Name" column="Name" type="String" length="100" not-null="false"/>
What I need to add in xml class to map CompanyName in my result?
here is my code...
public ArrayList getTest()
{
ISession session = NHibernateHelper.GetCurrentSession();
string query = "select Employee.*,(Company.Name)CompanyName from Employee inner join Employee on Employee.CompanyID = Company.CompanyID";
ArrayList document = (ArrayList)session.CreateSQLQuery(query, "Employee", typeof(Document)).List();
return document;
}
but in the returned result, I am getting CompanyName is null is result set and other columns are fine.
Note:In DB, tables don't physical relation
Please suggest my solution ------
Thanks