Quando la query di tabella contiene clausola di richiesta, la soluzione restituirà più elementi di quelli richiesti dalla query. Un piccolo cambiamento di espressione mentre risolverà quel problema.
public static async Task<IList<T>> ExecuteQueryAsync<T>(this CloudTable table, TableQuery<T> query, CancellationToken ct = default(CancellationToken), Action<IList<T>> onProgress = null) where T : ITableEntity, new()
{
var runningQuery = new TableQuery<T>()
{
FilterString = query.FilterString,
SelectColumns = query.SelectColumns
};
var items = new List<T>();
TableContinuationToken token = null;
do
{
runningQuery.TakeCount = query.TakeCount - items.Count;
TableQuerySegment<T> seg = await table.ExecuteQuerySegmentedAsync<T>(runningQuery, token);
token = seg.ContinuationToken;
items.AddRange(seg);
if (onProgress != null) onProgress(items);
} while (token != null && !ct.IsCancellationRequested && (query.TakeCount == null || items.Count < query.TakeCount.Value));
return items;
}
CURA: Grazie ad un suggerimento da PaulG, corretto il problema con il conteggio di risultato quando query contiene prendere clausola e ExecuteQuerySegmentedAsync
restituisce elementi in diversi passaggi.
Qualcuno può indicarmi un documento che parla dei metodi disponibili nell'API di archiviazione e che non si trovano su architetture diverse? È frustrante che i documenti e le guide introduttive dicano di fare una cosa e quindi i metodi non ci sono. – Rory