title: WCF - Instantiating an object in DataContract constructor
body: <p>I have two classes as below:</p>
  
  <pre><code>[DataContract]
  public class Address
  {
     [DataMember]
     public string Line1
     [DataMember]   
     public string Line2
     [DataMember]
     public string City
     [DataMember]
     public string State
     [DataMember]
     public string Zip
  }
  
  [DataContract]
  public class Customer
  {
     public Customer()
     {
        CustomerAddress = new Address();
     }
  
     [DataMember]
     public string FirstName
     [DataMember]
     public string LastName
     [DataMember]
     public Address CustomerAddress
  }
  </code></pre>
  
  <p>What will happen if i generate proxy of my service that uses Customer class? If i understand the concept correctly then i think the constructor in the Customer class will not be called at the client side and it may give different behavior.</p>
  
  <p>How do i get rid of that constructor in the Customer class and still have the <code>CustomerAddress</code> property of type <code>Address</code> so that it behaves as a dumb DTO object? </p>
  
  <p>What is the general guideline or best practices that people use to avoid this situation?</p>