Beispiel #1
0
 //--- 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);
 }
Beispiel #2
0
        public IDynamoTableTransactWriteItemsPutItem <TRecord> BeginPutItem <TRecord>(DynamoPrimaryKey <TRecord> primaryKey, TRecord record) where TRecord : class
        {
            var transactWriteItem = new TransactWriteItem {
                Put = new Put {
                    TableName = _table.TableName,
                    Item      = _table.SerializeItem(record, primaryKey),
                }
            };

            _request.TransactItems.Add(transactWriteItem);
            var converter = new DynamoRequestConverter(transactWriteItem.Put.ExpressionAttributeNames, transactWriteItem.Put.ExpressionAttributeValues, _table.SerializerOptions);

            return(new DynamoTableTransactWriteItemsPutItem <TRecord>(this, transactWriteItem.Put, converter));
        }
Beispiel #3
0
        public IDynamoTableTransactWriteItemsUpdateItem <TRecord> BeginUpdateItem <TRecord>(DynamoPrimaryKey <TRecord> primaryKey) where TRecord : class
        {
            var transactWriteItem = new TransactWriteItem {
                Update = new Update {
                    TableName = _table.TableName,
                    Key       = new Dictionary <string, AttributeValue> {
                        [primaryKey.PKName] = new AttributeValue(primaryKey.PKValue),
                        [primaryKey.SKName] = new AttributeValue(primaryKey.SKValue)
                    }
                }
            };

            _request.TransactItems.Add(transactWriteItem);
            var converter = new DynamoRequestConverter(transactWriteItem.Update.ExpressionAttributeNames, transactWriteItem.Update.ExpressionAttributeValues, _table.SerializerOptions);

            return(new DynamoTableTransactWriteItemsUpdateItem <TRecord>(this, transactWriteItem.Update, converter));
        }
        //--- Methods ---
        public IDynamoTableTransactGetItemsBegin <TRecord> BeginGetItem <TRecord>(DynamoPrimaryKey <TRecord> primaryKey, bool consistentRead = false) where TRecord : class
        {
            // transaction GetItem
            var transactGetItem = new TransactGetItem {
                Get = new Get {
                    TableName = _table.TableName,
                    Key       = new Dictionary <string, AttributeValue> {
                        [primaryKey.PKName] = new AttributeValue(primaryKey.PKValue),
                        [primaryKey.SKName] = new AttributeValue(primaryKey.SKValue)
                    }
                }
            };

            _request.TransactItems.Add(transactGetItem);

            // add expressions converter
            var converter = new DynamoRequestConverter(transactGetItem.Get.ExpressionAttributeNames, _table.SerializerOptions);

            _converters.Add(converter);

            // register expected type
            converter.AddExpectedType(typeof(TRecord));
            return(new DynamoTableTransactGetItemsEntry <TRecord>(this, converter));
        }
Beispiel #5
0
 //--- 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);
 }
 //--- Abstract Methods ---
 public abstract string GetKeyConditionExpression(DynamoRequestConverter converter);
 //--- Methods ---
 public override string GetKeyConditionExpression(DynamoRequestConverter converter)
 => $"{converter.GetAttributeName(PKName)} = {converter.GetExpressionValueName(PKValue)} AND {converter.GetAttributeName(SKName)} BETWEEN {converter.GetExpressionValueName(SortKeyLowerBound)} AND  {converter.GetExpressionValueName(SortKeyUpperBound)}";
 //--- Methods ---
 public override string GetKeyConditionExpression(DynamoRequestConverter converter)
 => $"{converter.GetAttributeName(PKName)} = {converter.GetExpressionValueName(PKValue)}";
 //--- Constructors ---
 public DynamoTableTransactGetItemsEntry(DynamoTableTransactGetItems parent, DynamoRequestConverter converter)
 {
     _parent    = parent ?? throw new ArgumentNullException(nameof(parent));
     _converter = converter ?? throw new ArgumentNullException(nameof(converter));
 }
 //--- 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);
 }
Beispiel #11
0
 //--- Constructors ---
 public DynamoTableTransactWriteItemsUpdateItem(DynamoTableTransactWriteItems parent, Update update, DynamoRequestConverter converter)
 {
     _parent    = parent ?? throw new ArgumentNullException(nameof(parent));
     _update    = update ?? throw new ArgumentNullException(nameof(update));
     _converter = converter ?? throw new ArgumentNullException(nameof(converter));
 }
Beispiel #12
0
 //--- Constructors ---
 public DynamoTableTransactWriteItemsPutItem(DynamoTableTransactWriteItems parent, Put put, DynamoRequestConverter converter)
 {
     _parent    = parent ?? throw new ArgumentNullException(nameof(parent));
     _put       = put ?? throw new ArgumentNullException(nameof(put));
     _converter = converter ?? throw new ArgumentNullException(nameof(converter));
 }
Beispiel #13
0
 //--- Constructors ---
 public DynamoTableTransactWriteItemsDeleteItem(DynamoTableTransactWriteItems parent, Delete delete, DynamoRequestConverter converter)
 {
     _parent    = parent ?? throw new ArgumentNullException(nameof(parent));
     _delete    = delete ?? throw new ArgumentNullException(nameof(delete));
     _converter = converter ?? throw new ArgumentNullException(nameof(converter));
 }
Beispiel #14
0
 //--- Constructors ---
 public DynamoTableTransactWriteItemsConditionCheck(DynamoTableTransactWriteItems parent, ConditionCheck conditionCheck, DynamoRequestConverter converter)
 {
     _parent         = parent ?? throw new ArgumentNullException(nameof(parent));
     _conditionCheck = conditionCheck ?? throw new ArgumentNullException(nameof(conditionCheck));
     _converter      = converter ?? throw new ArgumentNullException(nameof(converter));
 }