The mapping looks like this:

    <bag name="Lessons" table="StudentLessons" cascade="all-delete-
orphan" lazy="false" inverse="true" order-by="StartedOn desc">
      <key column="PeriodID" />
      <one-to-many class="StudentLesson" />
    </bag>


On 26 jul, 22:51, cliff vaughn <[email protected]> wrote:
> oops, sorry, ignore my reply, i see you say the "recommended" way isn't
> working.  back to the drawing board...
>
> On Mon, Jul 26, 2010 at 4:49 PM, cliff vaughn <[email protected]>wrote:
>
>
>
> > you don't want to code your Lessons property that way.  it should just
> > return lessons.  Your code would keep overriding the collections that NH
> > would've initialized your object with.
>
> > On Mon, Jul 26, 2010 at 4:39 PM, Anton <[email protected]> wrote:
>
> >> 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]<nhusers%[email protected]>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/nhusers?hl=en.
>
> > --
> > thanks
>
> > cliff
>
> --
> thanks
>
> cliff

-- 
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.

Reply via email to