I am attempting to implement Linq-to-SQL as the data access technology (ORM tool) on a DDD project. L2S was not my choice, but it is what I have to work with (for now).
Following DDD, I have my domain model already created and it is not going to match my normalized database schema. (Nothing unusual here). I am trying to implement L2S to use my domain objects as POCOs using the external XML mapping file as the MappingSource for my DataContext. All of this is well and good until I run into more complex mapping.
In my domain layer I have an Appointment class which has a child property of type Recurrence. Recurrence is a base class and the actual implementation is provided by various subclasses depending on the type of the recurrence pattern. From code, I can create the appropriate subclass using the RecurrenceFactory class. However, in my database, I simply have an Appointment table which has two columns: RecurrenceType and RecurrenceValue.
How do I setup the XML mapping file to use the RecurrenceFactory to create the appropriate subclass using the RecurrenceType and RecurrenceValue columns from the database?
If this is not do-able, then I have to completely change direction for my implementation. Your thoughts are appreciated!