NHibernate and XML Serialization with IList <T>
I recently started using NHibernate, and in general, how much it is.
Until I had a problem with the need for serialization in XML and vice versa.
I have a class that has many, many relationships, so in the parent class IList should contain a list of child objects.
Class parentClass{ IList<childClass> childList; string varA; string varB; } I need to be able to serialize this to XML and vice versa, but obviously IList forbids me to do this because NHibernate wants to control a particular IList implementation, in this case using Bag.
Ideally, I want to avoid having individual DTOs simply replace the list, since my main motivation for using NHibernate was able to use it with POCOs and I didn't need to prepare a nasty structure around it.
I know that I can take control of the serialization process using ISerializable, but then again, it seems like NHibernate is the first to replace in order to reduce complexity.
Also, XML should remain "simple" because it is used to interact with third parties.
What is the best way to get around this limitation?
Thanks!
Cm:
C # Castle ActiveRecord: how to elegantly (XML) serialize ActiveRecord objects?
How to serialize all properties of an object with NHibernate mapping?
NHibernate and WCF Serialization (Unidirectional)
JSON.NET and nHibernate Lazy Download Collections
What .NET JSON serializers can work with NHibernate proxy objects?
DTOs for serializing persistent objects
Return NHibernate mapping classes from WCF services
Bottom line: use DTO.