EntitySQL - left join problem
Posted: Wed 04 Aug 2010 11:00
I have this hypothetical scenario. An employee can be related with one or more departments. But in case of a relation only one department is his main department.
Three entities are involved 'Employee', 'Deparment' and 'EmplDepartment'.
At this point I have to use EntitySQL instead of LINQ To Entities, because my customers have different EntitySQL-statements which can be imported in my app.
I have define the following statement, which was translated to TSQL but Oracle throws an error 'invalid identifier' relating to the EmployeeID in a sub-select.
My EntitySQL:
string sql = "SELECT VALUE E FROM EmplEntities.Employees AS E WHERE E.EmployeeID=1";
var query = MyDbContext.CreateQuery(sql, new ObjectParameter[0]).
Select( empl => new {
EmplID = empl.EmployeeID,
EmplName = empl.EmployeeName,
MainDept = empl.EmployeeDepartments.Where(ed1 => ed1.IsMain ==true).Select(ed2 => ed.DepName).FirstOrDefault()
});
this.dataGridView1.DataSource = query.ToList();
Regards
bolek75
Three entities are involved 'Employee', 'Deparment' and 'EmplDepartment'.
At this point I have to use EntitySQL instead of LINQ To Entities, because my customers have different EntitySQL-statements which can be imported in my app.
I have define the following statement, which was translated to TSQL but Oracle throws an error 'invalid identifier' relating to the EmployeeID in a sub-select.
My EntitySQL:
string sql = "SELECT VALUE E FROM EmplEntities.Employees AS E WHERE E.EmployeeID=1";
var query = MyDbContext.CreateQuery(sql, new ObjectParameter[0]).
Select( empl => new {
EmplID = empl.EmployeeID,
EmplName = empl.EmployeeName,
MainDept = empl.EmployeeDepartments.Where(ed1 => ed1.IsMain ==true).Select(ed2 => ed.DepName).FirstOrDefault()
});
this.dataGridView1.DataSource = query.ToList();
Regards
bolek75