Is there a way to use a Join mapping in fluent nhibernate with a filter specified?
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?
精彩评论