I've implemented an event that is fired every time a value changes in a class. I also have a class that has a collection of those items and I'd like to subscribe to those items events. I'm trying to do so in the setter of a property like this:
public virtual ISet<ItemType> items
{
get
{
return this._items;
}
set
{
this._items = value;
foreach (var item in this._items)
{
item.PropertyChanged += this.Item_ThePropertyChanged;
}
}
}
But I get an "illegal access to loading collection" error as soon as we reach the "in this._items" from the "for" part. Here's the stack trace:
at NHibernate.Collection.AbstractPersistentCollection.Initialize(Boolean writing)\r\n at NHibernate.Collection.AbstractPersistentCollection.Read()\r\n at NHibernate.Collection.Generic.PersistentGenericSet`1.System.Collections.Generic.IEnumerable.GetEnumerator()\r\n at MyMethod
Thanks in advance for any help