Skip to content

Commit

Permalink
Merge pull request #7 from Azure-Samples/rework-result-parsing
Browse files Browse the repository at this point in the history
Rework query result parsing
  • Loading branch information
seesharprun authored Oct 11, 2023
2 parents 13f2a28 + 64f01f6 commit 9763bcc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/web/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,29 @@
using FeedIterator<Product> feed = container.GetItemQueryIterator<Product>(
queryDefinition: query
);
// </query_items>
await WriteToConsoleAync($"Ran query:\t{query.QueryText}");

// <parse_results>
List<Product> items = new();
double requestCharge = 0d;
while (feed.HasMoreResults)
{
FeedResponse<Product> response = await feed.ReadNextAsync();
foreach (Product item in response)
{
// Do something with each item
await WriteToConsoleAync($"Found item:\t{item.name}\t[{item.id}]");
items.Add(item);
}
await WriteToConsoleAync($"Request charge:\t{response.RequestCharge:0.00}");
requestCharge += response.RequestCharge;
}
// </query_items>
// </parse_results>
foreach(var item in items)
{
await WriteToConsoleAync($"Found item:\t{item.name}\t[{item.id}]");
}
await WriteToConsoleAync($"Request charge:\t{requestCharge:0.00}");
}

await WriteToConsoleAync("Current Status:\tStopping...");
Expand Down

0 comments on commit 9763bcc

Please sign in to comment.