Click here to Skip to main content
15,880,427 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the following request that gives me the data that I need. The problem I am having is that I need the Quantity summed and grouped by the remaining columns/objects. I have removed the html encoding to improve readability.

CustomerDocumentDetail?$expand=CustomerDocument($select=BuildingId,ServingSessionId,EligibilityStatusId,Date)&$filter=IsReimbursable eq true and month(CustomerDocument/Date) eq 3 and year(CustomerDocument/Date) eq 2022 and CustomerDocument/Status ne 'Voided'&$select=ItemId,Quantity,IsReimbursable&$top=2000


As mentioned, this request works but brings in around 320K recs (in 2K chunks) and takes over an hour to complete. Aggregation would produce around 2.6K recs and take about 10 seconds to complete.

Once more to clarify what I'm asking for help with. Given that my background is sql, let me express it that way:
SQL
Select BuildingId, ServingSessionId, EligibilityStatusId, [Date], ItemId, IsReimbursable, Sum(Quantity) as SumOfQuantity
From ...Where...
Group By BuildingId, ServingSessionId, EligibilityStatusId, [Date], ItemId, IsReimbursable


The vendor's documentation/schema UI is Swagger and it works great except it doesn't have a parameter slot to use the $apply directive for aggregates. I've tried sneaking it in in the select and expand to no avail.

What I have tried:

I've tried adding $apply to the request per the dozens of simplified aggregate examples I found but am greeted by a simple bad request error. I'm sure it's a simple syntax error but the server isn't giving back the error details. I'd like to test out the aggregate in the Swagger UI but after a few days, I still can't get it to work. If anyone is studying those weblogs, they are probably laughing!

Other/Background: I've been a developer for 22 years and have connected to and retrieved data from a variety of formats/endpoints/dbms but this is my first go with OData. Before getting into it, what I was expecting was that basically, it's sending a request, getting a response, and doing something with it. Google though, told me that I needed a special VS extension. I wasted half a day trying to get the extension to work, only to give up and use a simple httpwebrequest and json helper library to get it working. It works, but it's highly inefficient. Thanks in advance for any guidance here!
Posted
Updated 10-Jun-22 5:03am
v2

1 solution

The vendor will have to setup the odata feed for you I think. I don't know of any way off the top of my head to do this. I would probably reach out to the vendor and ask.

Or I would download the subset without any filtering etc.. and then group and sum in that. Which is as you have noted slower.

Sorry
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900