Question: Does anyone know if there is an alternative to using attributes on C# properties to map to XML nodes when using XmlSerializer?

My issue is that I have an object called `Article`, with some properties (e.g. ID, Title, Body) and I do not want to add attributes directly to it (used elsewhere, etc, etc)...so I created a partial class and re-defined the properties and added the attributes there, but soon discovered that you cannot have duplicate properties in partial classes. 

So I was wondering if anyone knew of any way that I could map the properties instead (in a similar fashion to n-hibernate, for example).

I'd appreciate any help.

Answer: 
There's a [constructor of the XmlSerializer](http://msdn.microsoft.com/en-us/library/bfaxz1a0.aspx) class that allows you to pass a [XmlAttributeOverrides](http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlattributeoverrides.aspx) and thus alter the behavior at runtime.

Quote from the documentation:

> 
> The overrides parameter can be used to control how fields and
>  properties are encoded in XML. These settings override any attributes
>  that already exist on the objects. This can be useful when the source
>  code cannot be modified or multiple encodings are required for the
>  same classes.
> 
> 
>
You could implement [IXmlSerializable](http://msdn.microsoft.com/en-us/library/system.xml.serialization.ixmlserializable.aspx) directly. It requires some more code, but you will have full control without the need for attributes.