I'm having an issue mapping what I would think is a fairly simple association.
Here's an example of the domain model I'm trying to map:
public class MyClass
{
IDictionary<string, DateTime> Dates { get; set; }
}
public class MyOtherClass
{
IDictionary<string, DateTime> Dates { get; set; }
}
I'd like the Dates property to be mapped into a single table, something like this:
TABLE Dates
COLUMNS
ParentId (Parent class key value)
ParentType (Parent class type)
DateType (Index value for dictionary)
DateValue
SAMPLE
ParentId ParentType DateType DateValue
----------------------------------------------------------
1 MyClass TYPEA 2009-10-09
1 MyOtherClass TYPEA 2009-11-08
I'm open to suggestions as to how to better model this, but basically I want a one to many association without littering the database with a separate table for every collection.
I'm using DateTime in this particular example as that's what I'm trying to do right now, but it could just as easily be any type, even another custom class that I would want to model in the same way.
Any idea as to how this should be mapped?
I believe this is similar to a question I had asked previously (http://stackoverflow.com/questions/722550/nhibernate-how-do-i-map-mutiple-parents-children-of-a-common-type-into-a-single) but that solution ended up in crosstables all over the place which isn't really the result I'm trying to achieve.