title: How to use async lambda with SelectMany?
body: <p>I'm getting the following error when trying to use an <code>async</code> lambda within <code>IEnumerable.SelectMany</code>:</p>
  
  <pre><code>var result = myEnumerable.SelectMany(async (c) =&gt; await Functions.GetDataAsync(c.Id));
  </code></pre>
  
  <blockquote>
    <p>The type arguments for method 'IEnumerable
    System.Linq.Enumerable.SelectMany(this
    IEnumerable, Func>)' cannot be
    inferred from the usage. Try specifying the type arguments explicitly</p>
  </blockquote>
  
  <p>Where <code>GetDataAsync</code> is defined as:</p>
  
  <pre><code>public interface IFunctions {
      Task&lt;IEnumerable&lt;DataItem&gt;&gt; GetDataAsync(string itemId);
  }
  
  public class Functions : IFunctions {
      public async Task&lt;IEnumerable&lt;DataItem&gt;&gt; GetDataAsync(string itemId) {
          // return await httpCall();
      }
  }
  </code></pre>
  
  <p>I guess because my <code>GetDataAsync</code> method actually returns a <code>Task&lt;IEnumerable&lt;T&gt;&gt;</code>. But why does <code>Select</code> work, surely it should throw the same error?</p>
  
  <pre><code>var result = myEnumerable.Select(async (c) =&gt; await Functions.GetDataAsync(c.Id));
  </code></pre>
  
  <p>Is there any way around this?</p>