title: XmlSerializer adds namespaces to all elements on serializing
body: <p>I have a Serialize function which serializes an entity (customer object). XmlSerializer is created using </p>
  
  <pre><code>          new XmlSerializer(entity.GetType())
  </code></pre>
  
  <p>I have two test cases which call this function. First test gets a a List of customers and sends one of the active customer to be serialized which works well. XML output that is created has namespace only in the root element (i.e. customer element/tag)</p>
  
  <p>Example:</p>
  
  <pre><code>&lt;Customer xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" domain="XXX" 
  sparse="false" xmlns="http://schema.xxx.com/finance/v3"&gt;
     &lt;Id&gt;1099&lt;/Id&gt;...
  </code></pre>
  
  <p>Second test calls a Customer queryservice and uses LinqExtender to query the results from query service and returns an active customer. When the second test calls the serialize method it causes the XML output to have namespace added to all the elements instead of having it only for the root element. </p>
  
  <p>Example:</p>
  
  <pre><code>&lt;Customer xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" domain="XXX" 
  sparse="false"&gt;
      &lt;Id xmlns="http://schema.xxx.com/finance/v3"&gt;1099&lt;/Id&gt;...
  </code></pre>
  
  <p>I compared the 2 objects used by both first and second test and they are identical.</p>
  
  <p>I want the serializer to act consistently in this case which would be creating XML output with namespaces only in the root element.</p>