有没有办法在流畅的 nhibernate 中使用指定过滤器的 Join 映射?
我有一个场景,我想创建一个映射类,该类从两个表中提取数据。例如,我的两个表是 Persons 和 PersonAddresses。我希望生成的映射类将这两个合并在一起,如下所示:
public class PersonWithAddress
{
public int ID { get; set; }
// person fields ..
// address fields
}
问题是每个人可以拥有多个地址,但只有一个地址被标记为他们的主要地址。这就是我想要拉入该实体的地址。所以我认为有一种方法可以在我的映射中使用 Join() 并在连接上指定一个过滤器,如下所示:
public PersonWithAddressMap()
{
Table("People");
Id(x => x.ID, "PersonID");
Map(x => x.FirstName);
// map all the person fields...
Join("PersonAddresses", pa =>
{
pa.Optional();
pa.Map(x => x.AddressLine1);
// map all the other address fields
// apply filtering
pa.Where(x => x.IsPrimary == true); // <-- does not exist
});
}
有人知道如何做到这一点吗?
I have a scenario where I want to create map a class that pulls data from two table together. For example, my two tables are Persons and PersonAddresses. I want the resulting mapped class to merge these two together like this:
public class PersonWithAddress
{
public int ID { get; set; }
// person fields ..
// address fields
}
The problem is each person can have more than one address, but only one address is marked as their primary address. That is the address I want to pull into this entity. So I thought there was a way to use Join() in my mapping and specify a filter on the join like this:
public PersonWithAddressMap()
{
Table("People");
Id(x => x.ID, "PersonID");
Map(x => x.FirstName);
// map all the person fields...
Join("PersonAddresses", pa =>
{
pa.Optional();
pa.Map(x => x.AddressLine1);
// map all the other address fields
// apply filtering
pa.Where(x => x.IsPrimary == true); // <-- does not exist
});
}
Anyone know of a way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论