//--- Constructors --- public DynamoTableQuery(DynamoTable table, QueryRequest request, ADynamoQueryClause <TRecord> queryClause) { _table = table ?? throw new ArgumentNullException(nameof(table)); _request = request ?? throw new ArgumentNullException(nameof(request)); _queryClause = queryClause ?? throw new ArgumentNullException(nameof(queryClause)); _converter = new DynamoRequestConverter(_request.ExpressionAttributeNames, _request.ExpressionAttributeValues, _table.SerializerOptions); }
/// <summary> /// Writes the given object to the DynamoDB table. Property name are case sensitive. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="item"></param> /// <param name="tbl"></param> private Task <Document> WriteToTableAsync(EntType item) { var itemJson = JsonConvert.SerializeObject(item); var doc = Document.FromJson(itemJson); return(DynamoTable.PutItemAsync(doc)); }
public Task <Document> GetByKeyAsync(Dictionary <string, DynamoDBEntry> key) { if (key == null) { throw new ArgumentNullException(nameof(key)); } return(DynamoTable.GetItemAsync(key)); }
//--- Constructors --- public DynamoTableTransactGetItems(DynamoTable table, TransactGetItemsRequest request) { _table = table ?? throw new ArgumentNullException(nameof(table)); _request = request ?? throw new ArgumentNullException(nameof(request)); _converters = _request.TransactItems .Select(transactItem => new DynamoRequestConverter(transactItem.Get.ExpressionAttributeNames, _table.SerializerOptions)) .ToList(); }
public void CreateDynamoDbIfDoesNotExist() { DynamoDbConfig config = GetDynamoDbConfig(); DynamoTable table = new DynamoTable(config, _client); table.CreateIfNotExist(); AssertDynamoDbExists(_tableName); }
/// <summary> /// Updates or Inserts the given item /// </summary> public Task <Document> UpdateAsync(EntType item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } var itemJson = JsonConvert.SerializeObject(item); var doc = Document.FromJson(itemJson); return(DynamoTable.UpdateItemAsync(doc)); }
//--- Methods --- public override async Task InitializeAsync(LambdaConfig config) { _table = new DynamoTable( config.ReadDynamoDBTableName("GameTable"), new AmazonDynamoDBClient() ); _gameStateMachine = config.ReadText("GameLoopStateMachine"); _stepFunctionsClient = new AmazonStepFunctionsClient(); _lambdaClient = new AmazonLambdaClient(); _gameTurnFunctionArn = config.ReadText("GameTurnFunction"); }
public void CanHandleConcurrentCalls() { DynamoDbConfig config = GetDynamoDbConfig(); var table = new DynamoTable(config, _client); var tasks = Enumerable.Repeat(Task.Factory.StartNew(table.CreateIfNotExist), 10); Task.WaitAll(tasks.ToArray()); AssertDynamoDbExists(_tableName); }
//--- Methods --- public override async Task InitializeAsync(LambdaConfig config) { // initialize Lambda function _lambdaClient = new AmazonLambdaClient(); _amaClient = new AmazonApiGatewayManagementApiClient(new AmazonApiGatewayManagementApiConfig { ServiceURL = config.ReadText("Module::WebSocket::Url") }); _table = new DynamoTable( config.ReadDynamoDBTableName("GameTable"), new AmazonDynamoDBClient() ); _gameApiUrl = config.ReadText("RestApiUrl"); }
public void CanReadAndWriteData() { var client = new AmazonDynamoDBClient(RegionEndpoint.EUWest1); const string itemId = "1"; var provider = new DynamoStore(new DynamoDBContext(client)); var config = GetDynamoDbConfig(); var table = new DynamoTable(config, client); table.CreateIfNotExist(); provider.Save(new FakeDynamoItem { Id = itemId }, new DynamoDBOperationConfig()); var result = provider.Read <FakeDynamoItem>(itemId, new DynamoDBOperationConfig()); Assert.IsNotNull(result); Console.WriteLine(result.Id); Assert.AreEqual(result.Id, itemId); }
//--- Constructors --- public ThriftBooksDataAccessTests(DynamoDbFixture dynamoDbFixture, ITestOutputHelper output) : base(dynamoDbFixture, output) { DataAccessClient = new ThriftBooksDataAccessClient(dynamoDbFixture.TableName, dynamoDbFixture.DynamoClient); Table = new DynamoTable(TableName, DynamoClient, ThriftBooksDataAccessClient.TableOptions); }
//--- Constructors --- public DynamoTableDeleteItem(DynamoTable table, DeleteItemRequest request) { _table = table ?? throw new ArgumentNullException(nameof(table)); _request = request ?? throw new ArgumentNullException(nameof(request)); _converter = new DynamoRequestConverter(_request.ExpressionAttributeNames, _request.ExpressionAttributeValues, _table.SerializerOptions); }
//--- Constructors --- public DynamoTableTransactGetItems(DynamoTable table, TransactGetItemsRequest request) { _table = table ?? throw new ArgumentNullException(nameof(table)); _request = request ?? throw new ArgumentNullException(nameof(request)); _converters = new List <DynamoRequestConverter>(); }
//--- Constructors --- public DynamoTableBatchGetItems(DynamoTable table, BatchGetItemRequest request) { _table = table ?? throw new ArgumentNullException(nameof(table)); _request = request ?? throw new ArgumentNullException(nameof(request)); _converter = new DynamoRequestConverter(request.RequestItems.Single().Value.ExpressionAttributeNames, _table.SerializerOptions); }
//--- Constructors --- public DynamoTableTransactWriteItems(DynamoTable table, TransactWriteItemsRequest request) { _table = table ?? throw new ArgumentNullException(nameof(table)); _request = request ?? throw new ArgumentNullException(nameof(request)); }