经过无数小时的尝试使 Entity Framework 与 Oracle 一起工作,我已经放弃并开始了 NHibernate 的道路。
我有点用术语挣扎,有一个问题。给定以下类,我如何使 NHibernate (Fluent Mappings) 输出类似于下面的 SQL,使用WriteOffApprovalUser.UserName
作为字段的键Employee.MailID
。
C# 类
public class WriteOffApprovalUser : EntityBase<WriteOffApprovalUser>
{
public virtual string UserName { get; set; }
public virtual Employee.Employee Employee { get; set; }
}
public class Employee : EntityBase<Employee>
{
public virtual string EmployeeID { get; set; }
public virtual string EmployeeStatusCode { get; set; }
public virtual string FirstName { get; set; }
public virtual string LastName { get; set; }
public virtual string PreferredName { get; set; }
public virtual string JobTitle { get; set; }
public virtual string Division { get; set; }
public virtual string Department { get; set; }
public virtual string Location { get; set; }
public virtual string City { get; set; }
public virtual string DeskLocation { get; set; }
public virtual string MailID { get; set; }
public virtual string Phone { get; set; }
public virtual string Fax { get; set; }
public virtual string SecCode { get; set; }
public virtual string SupervisorID { get; set; }
}
SQL
SELECT c.user_name,
a.LAST_NAME
|| ', '
|| DECODE (a.PREFERRED_NAME, ' ', a.FIRST_NAME, a.preferred_name)
writeoff_approval_name
FROM writeoff_approval_user c, adp_employee a
WHERE c.USER_NAME = a.USER_ID AND c.exp_date IS NULL
ORDER BY 2