I've recently started using NHibernate, and on the whole like it a lot.
Until I ran into a problem with needing to serialize to XML and back.
I have a class that has a many to many relationship, so have an IList in the parent class to hold the list of child objects.
Class parentClass{
IList<childClass> childList;
string varA;
string varB;
}
I need to be able to serialize this to XML and back, but obviously the IList prevents me from doing this, due to NHibernate wanting to control the concrete implementation of the IList, in this case using a Bag.
Ideally I want to avoid having separate DTOs just to replace the list, as my main motivation for using NHibernate was being able to use it with POCOs and not have to cook up a nasty framework around it.
I'm aware of being able to take control of the serialization process with ISerializable, but again that seems to negate the point of using NHibernate in the first place to reduce complexity.
Also the XML needs to remain 'plain' as it is used to inter-operate with third parties.
What's the best way to work around this constraint?
Thanks!