title: Calling async methods from a WCF service
body: <p>I want to call asynchronous methods from a WCF service, something like:</p>
  
  <pre><code>[ServiceContract]
  interface IService
  {
      [OperationContract]
      int SomeMethod(int data);
  }
  
  int SomeMethod(int data)
  {
      var query = ... build LINQ query;
      var response = await query.ToListAsync();
      return response.Length;
  }
  </code></pre>
  
  <p>I don't want to add <code>async</code> to the <code>IService</code> interface or <code>SomeMethod</code> method. Using asynchronous methods is an internal issue that shouldn't be reflected in the interface.</p>
  
  <p>How can I do that?</p>
  
  <p>CLARIFICATION:</p>
  
  <p>My problem here is using <code>await</code> in a non-<code>async</code> method. I don't want the service contract to change (the client doesn't necessarily know what <code>async</code> is), and I don't want to split the method into <code>BeginSomeMethod</code> and <code>EndSomeMethod</code>. I want one method that uses <code>await</code> <em>internally</em>.</p>