title: WCF serialization and Value object pattern in Domain Driven Design
body: <p>The book Domain Driven Design by Eric Evans describes pattern called value object. One of the important characteristics of a value object is that it is immutable. </p>
  
  <p>As an example I have a value object "Clinic" which <strong>must</strong> have a name and an id. To make it a value object I do not provide setters on name and id. Also to make sure that there is not invalid instance I take name and id in a constructor and do not provide at parameter less constructor.</p>
  
  <p>public class Clinic 
  {</p>
  
  <pre><code>public Clinic(string name, string id)
  {
      Name = name;
      Id = id;  
  }
  
  public string Name{get; private set;}
  public string Id{get; private set;}
  </code></pre>
  
  <p>}</p>
  
  <p>The problem is that when I try to return this object from a WCF Service I get an exception that the object does not have parameter less constructor and the properties do not have public setters. I want to avoid adding parameter less constructor and public setters because then my domain model pattern goes for a toss. How can I get around this problem?</p>
  
  <p>Regards,
  Unmesh</p>