我有一个简单的实体
public Employee
{
public int Id {get; set;}
public string Name {get; set;}
public int ManagerId {get; set;}
}
然后我有一个LLBLGen查询
var employeeQuery = qf.Create()
.From(qf.Employee
.LeftJoin(EmployeeEntity.Relations.EmployeeEntityUsingManagerId))
.Select(()=> new RptEmployee()
{
Id = EmployeeFields.Id.ToValue<int>(),
EmployeeName = EmployeeFields.Name.ToValue<string>(),
ManagerName = HOW?
});
如何从自加入查询中获取经理名称?
答案 0 :(得分:1)
在这种情况下,您必须使用别名。大约代码:
var employeeQuery = qf.Create()
.From(qf.Employee
.LeftJoin(EmployeeEntity.Relations.EmployeeEntityUsingManagerId, "emp", "man"))
.Select(() => new RptEmployee()
{
Id = EmployeeFields.Id.Source("emp").ToValue<int>(),
EmployeeName = EmployeeFields.Name.Source("emp").As("EmployeeName").ToValue<string>(),
ManagerName = EmployeeFields.Name.Source("man").As("ManagerName").ToValue<string>()
});