I'm currently trying to bind a datagrid to a generic ISet. I've found many advices how to go ahead with this topic but I cannot believe that there's nothing included in NHibernate to bind UI controls to NHibernate-collections.
I tried to follow the solution above but in that case I've to implement a class for every object. When I implement a generic class I get the error, that ISet<T> cannot be converted to T[] set.CopyTo(this, 0) is executed.
Has anybody a code-sample how to bind a datagrid to an ISet? Any changes made to the data (update, insert, delete) should be handled by the binding...
Here is my coding how I tried to copy an ISet to a BindingList...
Code:
public class BindableList<T> : BindingList<T>
{
ISet<T> _set;
public BindableList(ISet<T> set)
{
set.CopyTo(this, 0);
this._set = set;
}
protected override void RemoveItem(int index)
{
base.RemoveItem(index);
this._set.Remove(base[index]);
}
protected override void InsertItem(int index, T item)
{
base.InsertItem(index, item);
this._set.Add(item);
}
}