2014-03-31 65 views
0

我有一個簡單的實體LLBLGEN臨自加入與查詢指定

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? 
        }); 

我如何從自managername連接查詢?

回答

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>() 
     });