Wondering if there is a good way(generic method which is) that can dynamically add child entity to appropriate entity set of a parent. Right now I have to do something like this, and it's not very elegant:
public int AppendChild<T>(PATIENT patient, T child)
where T : EntityBase
switch (typeof(T).Name)
{
case "EYE_EXAM":
patient.EYE_EXAMS.Add((EYE_EXAM)child);
break;
case "LEGS_EXAM":
patient.LEGS_EXAMS.Add(LEGS_EXAM)child);
break;
//etc, a very long list of possible types goes here
}
Is there better way to do this? Thanks for answers
or