It is in my ViewModel and I do the following:
I pass in a DrugDosageEntity to my ViewModel. When the user fills out a DrugDosageLimit on my dialog that is bound to the ViewModel, they can add it to a temporary list by clicking a button which is bound to a Command on my ViewModel. The CommandParameter is the new DrugDosageLimitEntity they want to add. This adds it to a list in the view model but does not add it to the DrugDosageEntity just yet.
The code for this is:
// DosageIntervalLimits is just a temporary list to hold all of my limits until the user saves.
DosageIntervalLimits.Add(dosageIntervalLimit);
// I reinitialize my WorkingDosageLimit so I can add add the next limit if necessary
InitializeWorkingDrugDosageLimit();
When the user has added all of the limits they need, they click the Save Command Button which fires the following in my ViewModel and actually adds the Limits to the Dosage.
foreach (DosageIntervalLimitOnDrugDosageEntity drugDosageLimit in DosageIntervalLimits)
drugDosageLimit.DrugDosage_ = DrugDosage;
I do not add directly to the list. I set the DrugDosage_ on the DrugDosageLimitEntity which adds it to the DrugDosageEntity's DrugDosageLimitsList_.
If you want I could create a small sample project to demonstrate the problem.
Thanks