title: How to get the sum of child records using web api odata?
body: <p>How do I return the total of the OrderItems prices (ItemTotalPrice) in web api odata? </p>
  
  <p>It looks like web api odata does not support $apply as described here: <a href="http://docs.oasis-open.org/odata/odata-data-aggregation-ext/v4.0/cs01/odata-data-aggregation-ext-v4.0-cs01.html#_Aggregation_Methods_1" rel="nofollow">http://docs.oasis-open.org/odata/odata-data-aggregation-ext/v4.0/cs01/odata-data-aggregation-ext-v4.0-cs01.html#_Aggregation_Methods_1</a></p>
  
  <p>I have an web api odata query like:</p>
  
  <pre><code>http://localhost:29446/odata/OrderItems
  </code></pre>
  
  <p>which returns the following json:</p>
  
  <pre><code>{
    "odata.metadata": "http://localhost:29446/odata/$metadata#OrderItems",
    "value": [{
      "OrderItemID": 17,
      "ItemDescription": "test",
      "ItemQty": 1,
      "ItemUnitPrice": "1.10",
      "ItemTaxGroup": 1,
      "ItemTotalTax": "0.10",
      "ItemTotalPrice": "1.22",
      "ItemSubProgram": 1,
      "ItemAccount": 1,
      "ItemActualCost": "1.22",
      "OrderID": 3
    }, {
      "OrderItemID": 18,
      "ItemDescription": "test",
      "ItemQty": 1,
      "ItemUnitPrice": "1.10",
      "ItemTaxGroup": 1,
      "ItemTotalTax": "0.10",
      "ItemTotalPrice": "1.10",
      "ItemSubProgram": 1,
      "ItemAccount": 1,
      "ItemActualCost": "1.00",
      "OrderID": 3
    }, {
      "OrderItemID": 19,
      "ItemDescription": "test",
      "ItemQty": 1,
      "ItemUnitPrice": "1.10",
      "ItemTaxGroup": 1,
      "ItemTotalTax": "0.10",
      "ItemTotalPrice": "1.10",
      "ItemSubProgram": 1,
      "ItemAccount": 1,
      "ItemActualCost": "1.00",
      "OrderID": 3
    }, {
      "OrderItemID": 20,
      "ItemDescription": "test",
      "ItemQty": 1,
      "ItemUnitPrice": "1.10",
      "ItemTaxGroup": 1,
      "ItemTotalTax": "0.10",
      "ItemTotalPrice": "1.10",
      "ItemSubProgram": 1,
      "ItemAccount": 1,
      "ItemActualCost": "1.00",
      "OrderID": 3
    }, {
      "OrderItemID": 21,
      "ItemDescription": "test",
      "ItemQty": 1,
      "ItemUnitPrice": "1.10",
      "ItemTaxGroup": 1,
      "ItemTotalTax": "0.10",
      "ItemTotalPrice": "1.10",
      "ItemSubProgram": 1,
      "ItemAccount": 1,
      "ItemActualCost": "1.00",
      "OrderID": 3
    }]
  }
  </code></pre>
  
  <p>I thought the below might work:</p>
  
  <pre><code>http://localhost:29446/odata/OrderItems?$apply=aggregate(ItemTotalPrice with sum as Total)
  </code></pre>
  
  <p>but I get the following error:</p>
  
  <pre><code>The query parameter '$apply' is not supported.
  </code></pre>
  
  <p>I am using OData v4 with Web API 2.2</p>