I've improved my sample as follows:
// Class variable
IList<StudentLesson> lessons = new List<StudentLesson>();
// This code doesn't work
public virtual IList<StudentLesson> Lessons {
get { return lessons; }
set { lessons = value; }
}
// This code works perfectly
public virtual IList<StudentLesson> Lessons {
get {
if (lessons.Count == 0)
lessons = new List<StudentLesson>();
return lessons;
}
set { lessons = value; }
}
Can it be a mapping issue? That the bag isn't initialized correctly
somehow? The reason I ask is because If
I just initialize the StudentPeriod myself it just works how it is
supposed to work (without the fix). However when
I retrieve the object from the database and when the object has an
empty collection it will not work without the fix.
I guess I'm doing something wrong but I have no idea what :)
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.