My MVC application essentially has two levels of mapping (simplified for this question):
RepositoryObject <-> Entity <-> ViewModel
We have created two profiles, each handling the configuration for the appropriate mapping level.
The "RepositoryObjects" are eventually serialised to XML and used in REST web services. The problem we found was that an empty collection in the RepositoryObject would serialise down to an empty element in the XML, and this would cause an issue as the web service is either expecting no element, or an element containing data.
We were able to resolve this using the AllowNullCollections configuration setting. This will (of course) create a null collection rather than an empty collection, which then serialises fine.
However I'm not entirely comfortable having this as a global setting as because as Jimmy has pointed out, its not really best practice. I'm happy to have it in the RepositoryObject <-> Entity
mapping because the RepositoryObjects are auto-generated (so are ugly anyway) and its very low-level in the application. But I'd prefer to not "corrupt" the Entity <-> ViewModel
mapping if possible.
So, is it possible to configure this setting per profile?
Thanks.
--
You received this message because you are subscribed to the Google Groups "AutoMapper-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/automapper-users/-/fG3koTLfYLoJ.
To post to this group, send email to automapp...@googlegroups.com.
To unsubscribe from this group, send email to automapper-use...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/automapper-users?hl=en.