I'm using Fluent NHibernate and I have two tables:
BusinessPlan [Id, Year, CustomerCode]
PreviousYearData [Id, Year, CustomerCode, MoreFieldsForData]
In my domain, I want to join PreviousYearData to the BusinessPlan to make entities something like this:
public class BusinessPlan {
public Guid Id { get; set; }
public int Year { get; set; }
public string CustomerCode { get; set; }
public PreviousYearData PreviousYearData {get; set;}
}
public class PreviousYearData {
public Guid Id { get; set; }
public int Year { get; set; }
public string CustomerCode { get; set; }
// many more fields
}
The data in the PreviousYearData table gets prepopulated at the beginning of the year before the BusinessPlans will have been created, so I won't know what the BusinessPlan's Id will be and can't create a normal foreign key. What I think I want to do is join the PreviousYearData to BusinessPlan based on the two columns Year and CustomerCode. Is this possible with Fluent NHibernate? Is there another way to approach this that makes more sense?