title: Cast a Task<T> to a T
body: <p>How do I cast an <code>Task&lt;IEnumerable&lt;IMapLocationItem&gt;&gt;</code> to an <code>IEnumerable&lt;IMapLocationItem&gt;</code>?</p>
  
  <p>Here is my code that gets a <code>Task&lt;IEnumerable&lt;IMapLocationItem&gt;&gt;</code>:</p>
  
  <pre><code>public async Task&lt;IEnumerable&lt;IMapLocationItem&gt;&gt; GetAllMapLocationItemsFromUserName(string userName)
  {
      IEnumerable&lt;IMapLocationItem&gt; mapLocationImageGalleries = await db.mapLocationImageGalleries.Where(m =&gt; m.userName.Equals(userName)).ToListAsync();
      IEnumerable&lt;IMapLocationItem&gt; mapLocationVideoGalleries = await db.mapLocationVideoGalleries.Where(m =&gt; m.userName.Equals(userName)).ToListAsync();
  
      IEnumerable&lt;IMapLocationItem&gt; mapLocationItemsCombined = mapLocationImageGalleries.Concat(mapLocationVideoGalleries);
      return mapLocationItemsCombined;
  }
  </code></pre>
  
  <p>I can use the keyword <code>.Result</code>, but I have read somewhere that this prevents the <code>async</code> task from being asynchronous, and this method takes a very long time to finish when using the Result keyword.</p>
  
  <p>How is the best way to cast a <code>Task&lt;IEnumerable&lt;IMapLocationItem&gt;&gt;</code> to an <code>IEnumerable&lt;IMapLocationItem&gt;</code>?</p>
  
  <p>Thanks in advance</p>