title: Using Kendo UI DataSourceResponse with ASP.NET Web API DTOs
body: <p>I'm attempting to populate a Kendo UI Grid with an object, however I'm using a DTO instead of the Entity Framework object that's defined in my database. The problem is that my DataSourceResult expects an object in the form of an IQueryable and my DTO is of a type List. Here is my Invoice object:</p>
  
  <pre><code>Public Class Invoice
  
      &lt;Key&gt;
      Public Property InvoiceID As Integer
  
      Public Property Price As Double
  
      Public Property AmountPaid As Double
  
      Public Property Status As InvoiceStatus
  
      &lt;StringLength(10000)&gt;
      Public Property Memo As String
  
      Public Property Client As Client
  
      Public Property ClientID As Integer
  
  End Class
  </code></pre>
  
  <p>And here is my DTO:</p>
  
  <pre><code>Public Class InvoiceDTO
  
      Public Property InvoiceID As Integer
  
      Public Property InvoiceDate As Date
  
      Public Property Price As Double
  
      Public Property AmountPaid As Double
  
      Public Property Status As String
  
      Public Property Memo As String
  
      Public Property Client As String
  
      Public Property ClientID As Integer
  
  End Class
  </code></pre>
  
  <p>I'm using the following code in my GET in my API to return the object to my Grid. I want to return a DataSourceResult as opposed to a List because I can use the paging and sorting functions to return data from my API as efficiently as possible.</p>
  
  <pre><code>&lt;HttpGet, Route("api/client/all/invoices/{InvoiceStatus:int}")&gt;
  Public Function GetInvoices(requestMessage As HttpRequestMessage) As DataSourceResult
  
  
      Dim Invoices As IEnumerable(Of Invoice) = _db.Invoices.Include("Client").OrderBy(Function(i) i.InvoiceDate)
  
      Dim invDTOs As New List(Of InvoiceDTO)
  
      For Each inv As Invoice In Invoices
          Dim invDTO As New InvoiceDTO
          invDTO.Client = inv.Client.Name
          invDTO.ClientID = inv.ClientID
          invDTO.Memo = inv.Memo
          invDTO.InvoiceDate = inv.InvoiceDate
          invDTO.Price = inv.Price
          invDTO.AmountPaid = inv.AmountPaid
          invDTO.Status = status(inv.Status)
  
          invDTOs.Add(invDTO)
      Next
  
      Dim result As New DataSourceResult()
  
      result.Data = invDTOs
      result.Total = invDTOs.Count
  
      Dim response As HttpResponseMessage = Request.CreateResponse(HttpStatusCode.Created, result)
  
      Return response
  
  End Function
  </code></pre>
  
  <p>I can't query the DTO because it's a list. I can set the Data property of the DataSourceRequest to my DTO, however then I lose the paging functionality of the DataSourceRequest object built in that works well with the Grid. How do I use a DTO with the DataSourceResult?</p>