title: Blazor - SortBy parameter for table column component
body: <p>I'm working with Blazor and want to be able to sort a data grid (table) by a given column through a SortBy parameter that takes a lambda expression. It would look something like this:</p>
  
  <pre class="lang-blazor prettyprint-override"><code>&lt;DataGrid Items="Orders"&gt;
    &lt;GridHeader&gt;
      &lt;GridColumn Label="Order Number" SortBy="@(order =&gt; order.OrderNumber)" /&gt;
      &lt;GridColumn Label="Order Date" SortBy="@(order =&gt; order.Date)" /&gt;
      &lt;GridColumn Label="Order Status" SortBy="@(order =&gt; order.Status)" /&gt;
      &lt;GridColumn Label="Number of Line Items" SortBy="@(order =&gt; order.LineItems.Count)" /&gt;
    &lt;/GridHeader&gt;
    &lt;GridRow Context="order"&gt;
      &lt;td&gt;@order.OrderNumber&lt;/td&gt;
      &lt;td&gt;@order.OrderDate&lt;/td&gt;
      &lt;td&gt;@order.Status&lt;/td&gt;
      &lt;td&gt;@order.LineItems.Count&lt;/td&gt;
    &lt;/GridRow&gt;
  &lt;/Table&gt;
  </code></pre>
  
  <p>The Grid component should be able to take an <code>IEnumerable</code> of any type (like <code>IEnumerable&lt;Order&gt;</code>), so the <code>&lt;DataGrid&gt;</code> component should have a generic type associated with it's row items, set via <code>@typeparam TableItem</code>. What I'm having trouble with is being able to reference that <code>TableItem</code> type within the <code>GridColumn</code> <code>SortBy</code> parameter. I need it so that my code editor (Visual Studio) recognizes the <code>TableItem</code> type within the <code>SortBy</code> lambda expression, so that (in this example) when I start to type <code>SortBy="@(order =&gt; order.)"</code> then it recognizes order as type <code>Order</code> and intellisense will bring up the properties of that type. I think the solution has something to do with using cascading parameters (<code>CascadingValue</code>) and <code>@typeparam</code>, but I haven't been able to get it to work, and wonder if perhaps there's a current limitation of Blazor that prevents this from working (for example, see <a href="https://github.com/dotnet/aspnetcore/issues/7268" rel="nofollow noreferrer">this github issue</a>, which is still open).</p>
  
  <p>Is this even possible, and if so, what's the approach I should be using here?</p>