I have a mapping challenge and would love some advice...
I have a class EmailTemplate that consists of the following properties...
- FromAddress
- Subject
- Body
I have several classes that need to use EmailTemplate like this...
Solution class...
- int ID
- string Title
- EmailTemplate NewAccountEmailTemplate
- EmailTemplate ResetPasswordEmailTemplate
Invitation class...
- int ID
- etc...
- EmailTemplate InvitationReminderEmailTemplate
So, you can see I have several classes that need to have properties that are email templates. I know this is sort of like mapping components, except I do not want to store the email template in the same table as the parent class.
Instead, I would like to store ALL email templates in a single table EmailTemplates. I would like to use something like this...
EmailTemplates table
- ParentID int
- Title nvarchar(100)
- FromAddress nvarchar(100)
- Subject nvarchar(200)
- Body nvarchar(max)
And I would like to have an email template be uniquely identified by the combination of the ParentID col and the Title col. Then, the data might look something like this for the Solution's New Account Email Template...
ParentID = 20 (example id for solution)
Title = "Solution New Account Email Template"
From = "
[email protected]"
Subject = "Test"
Body = "Test"
So, the combination of ParentID and Title would uniquely identify the email template and identify it as the exact one to use for Solution.NewAccouintEmailTemplate.
In an even better world, I would like to have my EmailTemplates table be something like this...
- ParentType
- ParentID
- Title
- etc...
where ParentType would be "Solution" or "Invitation", etc. Then, I would need to have a composite index that is based on three columns instead of two columns.
I do not even know where to start to map this kind of situation. I appreciate any help!