I am fairly new to NHibernate too, but for what its worth; here's my take on the matter:
The issue is that any code internal or external to your class will need to interface with the collection using the IList interface. This is because NHibernate assigns its own persistent collection implementation to your IList member variable when an instance of your class is created by an NHibernate session.
If any of your code casts the interface back to your assumed implementation (like ArrayList), then you will get a cast exception.
So, in answer to your question, you can use a strongly typed collection if you like, as long as all communication with the collection is performed via the IList interface. This of course negates the point of having a strongly typed collection in the first place.
One alternative you might explore is to create a strongly typed collection wrapper around a private IList member collection. Set the access strategy in the NHibernate mapping file to "field". Have another field in your class referencing the strongly typed instance (which just wraps your private IList). Then return your strongly typed collection in your getter.
I haven't tried this before, but it might work.
|