title: How to change return type in LINQ query
body: <p>I am searching for a good way to change the return type from
  <code>IEnumerable</code> in anonymousType to <code>IEnumerable&lt;(string Category, decimal averagePrice)&gt;</code></p>
  <pre><code>/// &lt;summary&gt;
  /// Gets the average price of each category's products.
  /// &lt;/summary&gt;
  /// &lt;returns&gt;The average price of each category's products.&lt;/returns&gt;
  public static IEnumerable&lt;(string Category, decimal averagePrice)&gt; AveragePrice()
  {
          List&lt;Product&gt; products = GetListProducts();
          var result = from p in products
               group p by p.Category into g
               select new { Category = g.Key, AveragePrice = g.Average(p =&gt; p.UnitPrice) };
          return (IEnumerable&lt;(string Category, decimal averagePrice)&gt;)result;
  
  }
  </code></pre>
  <p>The logic is good but my problem is how to receive the same result without an anonymous function- I think I should change the query to a LINQ operation for products list. I am currently trying to do this with casting, but this doesn't work because my unit tests throw an <code>InvalidCastException</code>.</p>
  <p>How can I do this properly?</p>