title: Use a shared datatype as DataContract in WCF
body: <p>From what I can see I have to create a "special" datatype for each kind of data I want to transfer over WCF, so if I have a shared class like</p>
  
  <pre><code>public class District
  {
      public long Id { get; set; }
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>and I want to send a District object using WCF, I have to create a datacontract and therefore I have to create a new WCF class</p>
  
  <pre><code>[DataContract]
  public class WCFDistrict
  {
      [DataMember]
      public long Id { get; set; }
  
      [DataMember]
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>And then when I use it in a WCF service in my implementation I have to parse the data from one object to the other</p>
  
  <pre><code>public WCFDistrict GetDistrict(long id)
  {
      var district = _districtRepository.GetDistrict(id);
      return new WCFDistrict {Id = district.Id, Name = district.Name};
  }
  </code></pre>
  
  <p>Is there someway to just reuse the shared class as a DataContract, without having those attributes on it? Or should I create a interface on the classes they can share so I can just cast it between them? Or something third?</p>