In the .NET library, how do I determine the RU board for a request. It returns IQueryable, and I'm not sure how to do this.
As a link provided by Mikhail, you need to call docs.AsDocumentQuery().ExecuteNextAsync
to get the result from the DocumentDB service, you can get RU for a request from FeedResponse<T>.RequestCharge
.
RU .NET Client SDK , . , RU , , :
public static class DocumentDBExtension
{
public static async Task<IEnumerable<TSource>> QueryWithRuLog<TSource>(this IQueryable<TSource> source)
{
List<TSource> items = new List<TSource>();
double totalRuCost = 0;
var query = source.AsDocumentQuery();
while (query.HasMoreResults)
{
var result =await query.ExecuteNextAsync<TSource>();
items.AddRange(result);
totalRuCost += result.RequestCharge;
}
Console.WriteLine($"RUs cost:{totalRuCost}");
return items;
}
}
var result=docs.QueryWithRuLog<CampaignMessage>();