【发布时间】:2014-08-01 19:21:03
【问题描述】:
我在任何地方都找不到这个,但它看起来很简单。所以,如果这是重复的,请原谅。
我有类似的东西:
public class Doctor : Entity
{
...some other properties here...
public virtual string Email { get; set; }
}
public class Lawyer : Entity
{
...some other properties here...
public virtual string Email { get; set; }
}
我想返回 Lawyers 表中没有电子邮件匹配的所有医生,例如:
select * from Doctors d
where d.Email not in
(select l.Email from Lawyers l where l.Email is not null)
或使用连接:
select d.* from Doctors d
left join Lawyers l on l.Email = d.Email
where l.Email is null
问题是电子邮件当然没有设置为外键。我在 Doctor 实体上没有映射到 Lawyer 的映射属性。
到目前为止我已经尝试过:
ICriteria criteria = Session.CreateCriteria(typeof(Doctor))
.CreateAlias("Lawyers.Email", "LawyerEmail", JoinType.LeftOuterJoin)
.Add(Restrictions.IsNull("LawyerEmail"));
return criteria.List<Doctor>();
但是,我收到“无法解析 MyPlatform.MyNamespace.Doctor 的财产律师”错误。任何想法如何设置我的 DoctorMap 并调整标准 tomfoolery 来实现这一点?
NHibernate 为输........Entity Framework 为赢....
【问题讨论】:
标签: nhibernate orm fluent-nhibernate foreign-keys left-join