title: Telerik ToDataSourceResult method causes NotSupportedException in oData DataServiceQuery
body: <p>I have a Telerik data grid hooked up to this controller (which performs an oData query to the Microsoft Dynamics 365 cloud service)</p>
  
  <pre><code>    [Route("orders")]
      public ActionResult Orders([DataSourceRequest] DataSourceRequest request)
      {
          var context = _dynamicsContextFactory.CreateContext();
  
          var orderHeaders = context.SalesOrderHeadersV2//TODO: filter to account for user's session// .Where(x =&gt; x.OrderingCustomerAccountNumber == "DE-001")
              .Select(
                  x =&gt; new OrderHeader()
                  {
                      SalesOrderNumber = x.SalesOrderNumber,
                      OrderTotalAmount = x.OrderTotalAmount,
                      SalesOrderOriginCode = x.SalesOrderOriginCode,
                      CustomerTransactionSettlementType = x.CustomerTransactionSettlementType,
                      OrderCreationDateTime = x.OrderCreationDateTime,
                      ConfirmedShippingDate = x.ConfirmedShippingDate,
                  });
          // this way does not work with the ToDataSourceResult which performs paging etc.    
          //  x =&gt; x.AutoMap&lt;OrderHeader&gt;());
  
          return Json(orderHeaders.ToDataSourceResult(request));
      }
  </code></pre>
  
  <p>Pagination works ok, but when I try grouping or sorting I get the following exception:</p>
  
  <blockquote>
    <p>The orderby query option cannot be specified after the select query option.</p>
  </blockquote>
  
  <p>It seems like I need to re-order how the DataServiceQuery is constructed, but I have no idea how.
  (If I made my API conform to oData specification and used <a href="https://demos.telerik.com/aspnet-mvc/grid/odata" rel="nofollow noreferrer">telerik's special handling for odata</a> would that help? or just move the same problem elsewhere.)</p>
  
  <p><strong>Extra info:</strong><br>
  I'd like to get automapper to work also, and I expect the root cause is similar.<br>
  Here's my View:</p>
  
  <pre><code>      @(Html.Kendo().Grid&lt;MyAccountApiController.OrderHeader&gt;()
            .Deferred()
            .Name("grid")
            .Columns(columns =&gt;
            {
                columns.Bound(x =&gt; x.SalesOrderNumber);
                columns.Bound(x =&gt; x.CustomerTransactionSettlementType);
                columns.Bound(x =&gt; x.ConfirmedShippingDate);
                columns.Bound(x =&gt; x.OrderCreationDateTime);
                columns.Bound(x =&gt; x.OrderTotalAmount);
                columns.Bound(x =&gt; x.SalesOrderOriginCode);
            })
            .HtmlAttributes(new { style = "height: 400px;" })
            .Scrollable()
            .Groupable()
            .Sortable()
            .Pageable(page =&gt;
                page
                    .Refresh(true)
                    .PageSizes(true)
                    .ButtonCount(5)
            )
            .DataSource(source =&gt;
                source
                    .Ajax()
                    .Read(read =&gt; read.Action("Orders", "MyAccountApi")
                    )
                    .PageSize(20)
  
            ))
  </code></pre>