public async Task <IList <T> > QueryAllAsync(DynamoQuery query) { query.TableName = tableName; var remaining = query.Limit; var result = new List <T>(); QueryResult a; do { a = await client.QueryAsync(query, retryPolicy).ConfigureAwait(false); foreach (var item in a.Items) { result.Add(item.As <T>()); } remaining -= a.Count; query.ExclusiveStartKey = a.LastEvaluatedKey; query.Limit = remaining; }while (a.LastEvaluatedKey != null && remaining >= 0); return(result); }
public async Task <QueryResult> QueryAsync(DynamoQuery query, RetryPolicy retryPolicy) { var retryCount = 0; Exception lastException; do { if (retryCount > 0) { await Task.Delay(retryPolicy.GetDelay(retryCount)).ConfigureAwait(false); } try { return(await QueryAsync(query).ConfigureAwait(false)); } catch (DynamoDbException ex) when(ex.IsTransient) { lastException = ex; } retryCount++; }while (retryPolicy.ShouldRetry(retryCount)); throw new DynamoDbException($"Error querying '{query.TableName}': {lastException.Message}", lastException); }
public async Task <IList <T> > QueryAsync(DynamoQuery query) { query.TableName = tableName; var result = await client.QueryAsync(query, retryPolicy).ConfigureAwait(false); return(new QueryResult <T>(result)); }
public async Task <QueryResult> QueryAsync(DynamoQuery query) { var httpRequest = Setup("Query", query.ToJson()); var json = await SendAndReadJsonElementAsync(httpRequest).ConfigureAwait(false); return(QueryResult.FromJsonElement(json)); }
public async Task <int> CountAsync(DynamoQuery query) { query.TableName = tableName; query.Select = SelectEnum.COUNT; var result = await client.QueryCount(query).ConfigureAwait(false); return(result.Count); }
public async Task <CountResult> QueryCountAsync(DynamoQuery query) { query.Select = SelectEnum.COUNT; var httpRequest = Setup("Query", query.ToJson()); string responseText = await SendAsync(httpRequest).ConfigureAwait(false); return(System.Text.Json.JsonSerializer.Deserialize <CountResult>(responseText)); }
public async Task <QueryResult> QueryAsync(DynamoQuery query) { var httpRequest = Setup("Query", query.ToJson()); var responseText = await SendAsync(httpRequest).ConfigureAwait(false); var responseJson = JsonObject.Parse(responseText); return(QueryResult.FromJson(responseJson)); }
public async Task <CountResult> QueryCountAsync(DynamoQuery query) { query.Select = SelectEnum.COUNT; var httpRequest = Setup("Query", query.ToJson()); var responseText = await SendAsync(httpRequest).ConfigureAwait(false); var responseJson = JsonObject.Parse(responseText); return(responseJson.As <CountResult>()); }
public Task <IReadOnlyList <T> > QueryAsync(params Expression[] expressions) { var e = new DynamoQueryExpression(PrimaryKey.Names, expressions); var query = new DynamoQuery { KeyConditionExpression = e.KeyExpression.Text, ExpressionAttributeNames = (e.HasAttributeNames) ? e.AttributeNames : null, ExpressionAttributeValues = e.AttributeValues, FilterExpression = e.FilterExpression?.Text }; return(QueryAsync(query)); }
public async Task <QueryResult> QueryAsync(DynamoQuery query) { #region Preconditions if (query == null) { throw new ArgumentNullException(nameof(query)); } #endregion var httpRequest = Setup("Query", query.ToJson()); var responseText = await SendAsync(httpRequest).ConfigureAwait(false); var responseJson = JsonObject.Parse(responseText); return(QueryResult.FromJson(responseJson)); }
public Task <IList <T> > QueryAsync(Query q) { var e = new DynamoQueryExpression(PrimaryKey.Names, q.Expressions); var query = new DynamoQuery { IndexName = q.Index?.Name, Limit = q.Take ?? 0, KeyConditionExpression = e.KeyExpression.Text, ExpressionAttributeNames = (e.HasAttributeNames) ? e.AttributeNames : null, ExpressionAttributeValues = e.AttributeValues, FilterExpression = e.FilterExpression?.Text }; if (q.Orders != null && q.Orders[0].IsDescending) { query.ScanIndexForward = false; } return(QueryAsync(query)); }