I have a class called WorkingDays, this class requires a collection of dates that are the dates of bank holidays. In our database we have a table that contains these dates – I want nhibernate to get all those dates and populate the bankHolidays collection.
The catch is however I do not have a table that represents the link in the database – it seems unnecessary really when all WorkingDays impls will have the exact same list of bank holiday dates.
So how can I map this without needing to add a foreign key? I hope the code below can illustrate better:
public class WorkingDays : Interval
{
public ICollection<DateTime> BankHolidays
{
get;
private set;
}
}
Is there a reason you need this as a collection on the entity itself? Why not have a seperate repository/DAO responsible for accessing this collection? If the data were fairly static, you could probably gain quite a bit by using second level caching on this as well.