Hi h1!
AFAIK, there is no way to get pure List<SomeClass> from NHibernate – only PersistentGenericBag<SomeClass> or an instance of another NHibernate aware collection (PersistentGeneric***<SomeClass> are built-in ones). You may even create your own collection (sample is in "\src\NHibernate.Test\UserCollection" – it is for non-generic collection, but it is not so hard to make it generic). The real problem is that you have to define “special” collection – one that will implement IPersistentCollection interface – to make NHibernate work. Another option is to use one of the built-in classes (PersistentGeneric***) but it is really unreasonable as you’ll get all the same stuff you have with built-in collections.
collection-type attribute must point to special helper class (it is even not a collection class at all!) that will tell NHibernate how it can make use of your own collection classes (either just one “pure” collection, or both of them “pure” collection and “persistent” collection.
I suppose it may be handy to “extend” built-in types (for example to implement IBindingList interface in persistent collection and have ListChanged event there), but not to “shrink” these classes to simple plain List<SomeClass>. BTW maybe you can extend collection to add “smart” serialization capabilities to it (serialize just what you need, excluding all the NHibernate internal stuff) – but I suppose it is easier to do outside of NHibernate.
2 Sergey
Maybe I’m missing something obvious, but do I have to implement my own PersistentGenericBag class (probably a BindingList<T> descendant, or a kind of wrapper?) to have IBindingList capabilities in persistent collections. I tried to wrap NHibernate collection into BindingList<T> in my class property setter, but it force NHibernate to retrieve all the collection – not a behaviour I want to have. Is it possible in principle to have “lazy” collection, which will implement IBindingList interface?
_________________ WBR, Igor
|