public static async Task <T[]> LookupAsync <T>(this ITableLookupStorage <T> table, string partitionKey, string rowKeyStart = null, string rowKeyEnd = null) where T : TableEntity { List <T> list = null; string continuationToken = null; while (true) { var segment = await table.LookupAsync(partitionKey, rowKeyStart, rowKeyEnd, continuationToken); if (list == null) { if (segment.ContinuationToken == null) { return(segment.Results); // optimization, skip allocating the list } list = new List <T>(); } if (segment.Results != null) { list.AddRange(segment.Results); } continuationToken = segment.ContinuationToken; if (continuationToken == null) { // Done return(list.ToArray()); } } }
public static Task <T[]> GetRowsWithPrefixAsync <T>( this ITableLookupStorage <T> table, string partitionKey, string rowKeyPrefix) where T : TableEntity { string rowKeyEnd = NextRowKey(rowKeyPrefix); return(table.LookupAsync(partitionKey, rowKeyPrefix, rowKeyEnd)); }