'Nhibernate : Inner join Sql statement to Nhibernate ORM
I have 2 tables
Employee
| Id | FirstName |
|---|---|
| 1 | chris |
| 2 | alex |
Salaries
| EmployeeId | Salary |
|---|---|
| 1 | 1000 |
| 2 | 2000 |
and the following SQL statement that i would like to translate it to Nhibernate syntax
SELECT S.Salary
FROM Salaries S INNER JOIN Employee E
ON s.EmployeeId = E.Id
WHERE E.Id = @id
What i have done so far:
public ActionResult Details(int id)
{
using (ISession session = NHIbernateSession.OpenSession())
{
var employees = session.QueryOver<Employee>().List();
var salaries = session.QueryOver<Salaries>().List();
return View(??);
}
}
What i would like is to get the Employee's salary based on their ID that is referenced to the Salaries table
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
