I have a weird issue with NHibernate, or more specific: binding empty
lists. For some reason if I bind a DataGridView to an object with an
empty list it will NOT be updated if I add new rows.

I have a StudentPeriod class with an IList<StudentLessons> property.
If I check the type of this property at run-time you will see the
folowing:
NHibernate.Collection.Generic.PersistentGenericBag`1[[MBMS.Business.Types.StudentLesson,
MBMS.Business, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]

I binded this IList<StudentLessons> property to a BindingSource. This
BindingSource has been bound to the datasource of a DataGridView. As
mentioned earlier, I cannot add new rows. It will not give any errors.
If I add 4 items to the IList within the DataGridView, the
BindingSource will also have 4 items. However every item does not have
any values. It's like the values are initalized and have not been
bound correctly to each column in the DataGridView.

Ok, so now the weird part. I tried something silly at run-time. Before
I bind to the BindingSource, I check whether the
NHibernate.Collection.Generic.PersistentGenericBag is empty (Count ==
0). If it is I set the property as follows:
period.Lessons = new IList<StudentLessons>();

Everything works this way!! The BindingSource items have all been
correctly set. If I change values in the DataGridView it works
perfectly.

So my question is this, how is this possible? What's the reason that
changing the property at run-time to an IList<StudentLesson> works and
the PersistentGenericBag that NHibernate generates default does not
work?

Any help is greatly appreciated!

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