title: WCF - return multiple records
body: <p>Last week I created an asmx web service which returns multiple rows using soap.</p>
  
  <p>I now moving onto WCF and am wanting to do the same.</p>
  
  <p>In my ASMX web service I am doing the following..</p>
  
  <pre><code>public class sample
  {
      public string Id { get; set; }
      public string Name { get; set; }
      public string NameOfFile { get; set; }
      //public int Distance { get; set; }
  }
  
  [WebMethod]
  public sample[] Test(int count, float lat, float lng)
  {
      DataTable dt = new Gallery().DisplayNearestByLatLong(count, lat, lng);
      var samples = new List&lt;sample&gt;();
  
      foreach (DataRow item in dt.Rows)
      {
          var s = new sample();
          s.Id = item[0].ToString();
          s.Name = item[1].ToString();
          s.NameOfFile = item[2].ToString();
          //s.Distance = (int)item[3];
  
          samples.Add(s);
      }
      return samples.ToArray();
  }
  </code></pre>
  
  <p>This code works great but now I want to do the same but using WCF.</p>
  
  <p>My current WCF files look like this (I copied a tutorial but have setup the data contract (which i think is needed?))</p>
  
  <pre><code>GalleryWebService.cs
  public class GalleryWebService : IGalleryWebService
  {
      public string GetData(int value)
      {
          return string.Format("You entered: {0}", value);
      }
  
      public CompositeType GetDataUsingDataContract(CompositeType composite)
      {
          return composite;
      }
  
      public CompositeType GetTestData()
      {
          return new CompositeType();
      }
  }
  </code></pre>
  
  <p><strong>IGalleryWebService.cs</strong></p>
  
  <pre><code>[ServiceContract]
  public interface IGalleryWebService
  {
      [OperationContract]
      string GetData(int value);
  
      [OperationContract]
      CompositeType GetDataUsingDataContract(CompositeType composite);
  
      [OperationContract]
      [WebGet(BodyStyle = WebMessageBodyStyle.Bare,
              RequestFormat = WebMessageFormat.Json,
              ResponseFormat = WebMessageFormat.Json,
              UriTemplate = "test/random")]
      CompositeType GetTestData();
  }
  
  [DataContract]
  public class CompositeType
  {
      [DataMember]
      string _id;
      public string Id
      {
          get { return _id; }
          set { _id = value; }
      }
  
      [DataMember]
      string _name = "Hello";
      public string Name
      {
         get { return _name; }
         set { _name = value; }
      }
  
      [DataMember]
      string _nameoffile = "Hello";
      public string NameOfFile
      {
         get { return _nameoffile; }
         set { _nameoffile = value; }
      }
  }
  </code></pre>
  
  <p>What is the best way to go about doing it and how? Your help is greatly appreciated!</p>
  
  <p>Thanks in advance.</p>