Пример #1
0
        public long Increment <T>(object hash, string fieldName, long amount = 1)
        {
            var type    = DynamoMetadata.GetType <T>();
            var request = new UpdateItemRequest
            {
                TableName        = type.Name,
                Key              = Converters.ToAttributeKeyValue(this, type.HashKey, hash),
                AttributeUpdates = new Dictionary <string, AttributeValueUpdate> {
                    {
                        fieldName,
                        new AttributeValueUpdate {
                            Action = AttributeAction.ADD,
                            Value  = new AttributeValue {
                                N = amount.ToString()
                            }
                        }
                    }
                },
                ReturnValues = ReturnValue.ALL_NEW,
            };

            var response = DynamoDb.UpdateItem(request);

            return(response.Attributes.Count > 0
                ? Convert.ToInt64(response.Attributes[fieldName].N)
                : 0);
        }
 public PocoDynamoExpression(Type type)
 {
     Type             = type;
     Table            = DynamoMetadata.GetType(type);
     ParamPrefix      = "p";
     Params           = new Dictionary <string, object>();
     ReferencedFields = new List <string>();
     Aliases          = new Dictionary <string, string>();
 }
Пример #3
0
        public IEnumerable <T> ScanAll <T>()
        {
            var type    = DynamoMetadata.GetType <T>();
            var request = new ScanRequest
            {
                Limit     = PagingLimit,
                TableName = type.Name,
            };

            return(Scan(request, r => r.ConvertAll <T>()));
        }
Пример #4
0
 public static List <T> ConvertAll <T>(this QueryResponse response)
 {
     return(response.Items
            .Select(values => DynamoMetadata.GetType <T>().ConvertTo <T>(values))
            .ToList());
 }