Configuration object for setting options on the DynamoDBContext. and individual operations.
Ejemplo n.º 1
0
        public DynamoDBFlatConfig(DynamoDBOperationConfig operationConfig, DynamoDBContextConfig contextConfig)
        {
            if (operationConfig == null)
            {
                operationConfig = _emptyOperationConfig;
            }
            if (contextConfig == null)
            {
                contextConfig = _emptyContextConfig;
            }

            bool   consistentRead    = operationConfig.ConsistentRead ?? contextConfig.ConsistentRead ?? false;
            bool   skipVersionCheck  = operationConfig.SkipVersionCheck ?? contextConfig.SkipVersionCheck ?? false;
            bool   ignoreNullValues  = operationConfig.IgnoreNullValues ?? contextConfig.IgnoreNullValues ?? false;
            string overrideTableName =
                !string.IsNullOrEmpty(operationConfig.OverrideTableName) ? operationConfig.OverrideTableName : string.Empty;
            string tableNamePrefix =
                !string.IsNullOrEmpty(operationConfig.TableNamePrefix) ? operationConfig.TableNamePrefix :
                !string.IsNullOrEmpty(contextConfig.TableNamePrefix) ? contextConfig.TableNamePrefix : string.Empty;
            bool   backwardQuery = operationConfig.BackwardQuery ?? false;
            string indexName     =
                !string.IsNullOrEmpty(operationConfig.IndexName) ? operationConfig.IndexName : string.Empty;

            ConsistentRead    = consistentRead;
            SkipVersionCheck  = skipVersionCheck;
            IgnoreNullValues  = ignoreNullValues;
            OverrideTableName = overrideTableName;
            TableNamePrefix   = tableNamePrefix;
            BackwardQuery     = backwardQuery;
            IndexName         = indexName;
        }
Ejemplo n.º 2
0
        public DataRepository(ILogger <DataRepository> logger)
        {
            _logger = logger;

            AWSConfigsDynamoDB.Context.TypeMappings[typeof(Church)] =
                new TypeMapping(typeof(Church), DdbTableNames.ChurchtableName);
            AWSConfigsDynamoDB.Context.TypeMappings[typeof(Family)] =
                new TypeMapping(typeof(Family), DdbTableNames.FamilytableName);
            AWSConfigsDynamoDB.Context.TypeMappings[typeof(Member)] =
                new TypeMapping(typeof(Member), DdbTableNames.MembertableName);

            var config = new Amazon.DynamoDBv2.DataModel.DynamoDBContextConfig
            {
                Conversion       = DynamoDBEntryConversion.V2,
                IgnoreNullValues = true
            };

            _ddbContext = new DynamoDBContext(new AmazonDynamoDBClient(), config);

            _churchesTable = _ddbContext.GetTargetTable <Church>(new DynamoDBOperationConfig {
                IgnoreNullValues = true
            });
            _familiesTable = _ddbContext.GetTargetTable <Family>(new DynamoDBOperationConfig {
                IgnoreNullValues = true
            });
            _membersTable = _ddbContext.GetTargetTable <Member>(new DynamoDBOperationConfig {
                IgnoreNullValues = true
            });
        }
Ejemplo n.º 3
0
        public IDynamoDBContext CreateContext()
        {
            var config = new DynamoDBContextConfig {
                Conversion = DynamoDBEntryConversion.V2
            };
            var dbContext = new DynamoDBContext(new AmazonDynamoDBClient(), config);

            return(dbContext);
        }
Ejemplo n.º 4
0
        public void TestContextConfig()
        {
            // Test in response to GitHub issue
            // https://github.com/aws/aws-sdk-net/issues/209
            var config = new DynamoDBContextConfig()
            {
                TableNamePrefix = "Test"
            };

            Assert.AreEqual("Test", config.TableNamePrefix);
        }
Ejemplo n.º 5
0
        private DynamoDBContext(IAmazonDynamoDB client, bool ownClient, DynamoDBContextConfig config)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            this.client    = client;
            this.tablesMap = new Dictionary <string, Table>();
            this.ownClient = ownClient;
            this.config    = config ?? new DynamoDBContextConfig();
        }
Ejemplo n.º 6
0
        public DynamoDbContext(IAmazonDynamoDB ddbClient,
                               IConfigurationHelper configurationHelper)
        {
            _ddbClient = ddbClient;
            this._configurationHelper = configurationHelper;
            var config = new Amazon.DynamoDBv2.DataModel.DynamoDBContextConfig {
                Conversion = DynamoDBEntryConversion.V2
            };

            _ddbContext = new DynamoDBContext(ddbClient, config);

            Initialize();
        }
Ejemplo n.º 7
0
        public DynamoDbContext(IAmazonDynamoDB ddbClient)
        {
            _ddbClient = ddbClient;

            var ddbConfig = new Amazon.DynamoDBv2.DataModel.DynamoDBContextConfig
            {
                Conversion = DynamoDBEntryConversion.V2
            };

            _dbContext = new DynamoDBContext(ddbClient, ddbConfig);

            Initialize();
        }
Ejemplo n.º 8
0
        private DynamoDBContext(IAmazonDynamoDB client, bool ownClient, DynamoDBContextConfig config)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            this.ConverterCache = new Dictionary <Type, IPropertyConverter>();
            this.ConverterCache.Add(typeof(S3Link), new S3Link.S3LinkConverter(this));
            this.Client             = client;
            this.tablesMap          = new Dictionary <string, Table>();
            this.ownClient          = ownClient;
            this.Config             = config ?? new DynamoDBContextConfig();
            this.StorageConfigCache = new ItemStorageConfigCache(this);
        }
        public DynamoDataStore()
        {
            // Check to see if a table name was passed in through environment variables and if so
            // add the table mapping.
            var tableName = Environment.GetEnvironmentVariable(USER_TABLENAME_ENVIRONMENT_VARIABLE_LOOKUP);

            if (!String.IsNullOrEmpty(tableName))
            {
                AWSConfigsDynamoDB.Context.TypeMappings[typeof(UserModel)] = new TypeMapping(typeof(UserModel), tableName);
            }

            var config = new DynamoDBContextConfig {
                Conversion = DynamoDBEntryConversion.V2
            };

            this.DDBContext = new DynamoDBContext(new AmazonDynamoDBClient(), config);
        }
Ejemplo n.º 10
0
        public DynamoDBFlatConfig(DynamoDBOperationConfig operationConfig, DynamoDBContextConfig contextConfig)
        {
            if (operationConfig == null)
            {
                operationConfig = _emptyOperationConfig;
            }
            if (contextConfig == null)
            {
                contextConfig = _emptyContextConfig;
            }

            bool   consistentRead            = operationConfig.ConsistentRead ?? contextConfig.ConsistentRead ?? false;
            bool   skipVersionCheck          = operationConfig.SkipVersionCheck ?? contextConfig.SkipVersionCheck ?? false;
            bool   ignoreNullValues          = operationConfig.IgnoreNullValues ?? contextConfig.IgnoreNullValues ?? false;
            bool   isEmptyStringValueEnabled = operationConfig.IsEmptyStringValueEnabled ?? contextConfig.IsEmptyStringValueEnabled ?? false;
            string overrideTableName         =
                !string.IsNullOrEmpty(operationConfig.OverrideTableName) ? operationConfig.OverrideTableName : string.Empty;
            string tableNamePrefix =
                !string.IsNullOrEmpty(operationConfig.TableNamePrefix) ? operationConfig.TableNamePrefix :
                !string.IsNullOrEmpty(contextConfig.TableNamePrefix) ? contextConfig.TableNamePrefix : string.Empty;
            bool   backwardQuery = operationConfig.BackwardQuery ?? false;
            string indexName     =
                !string.IsNullOrEmpty(operationConfig.IndexName) ? operationConfig.IndexName : DefaultIndexName;
            List <ScanCondition>      queryFilter         = operationConfig.QueryFilter ?? new List <ScanCondition>();
            ConditionalOperatorValues conditionalOperator = operationConfig.ConditionalOperator;
            DynamoDBEntryConversion   conversion          = operationConfig.Conversion ?? contextConfig.Conversion ?? DynamoDBEntryConversion.CurrentConversion;

            ConsistentRead            = consistentRead;
            SkipVersionCheck          = skipVersionCheck;
            IgnoreNullValues          = ignoreNullValues;
            IsEmptyStringValueEnabled = isEmptyStringValueEnabled;
            OverrideTableName         = overrideTableName;
            TableNamePrefix           = tableNamePrefix;
            BackwardQuery             = backwardQuery;
            IndexName           = indexName;
            QueryFilter         = queryFilter;
            ConditionalOperator = conditionalOperator;
            Conversion          = conversion;

            State = new OperationState();
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Constructs a DynamoDBContext object with the specified configuration.
 /// Uses a default AmazonDynamoDBClient as the client.
 /// </summary>
 /// <param name="region">The region to configure the AmazonDynamoDBClient to use.</param>
 /// <param name="config"></param>
 public DynamoDBContext(RegionEndpoint region, DynamoDBContextConfig config)
     : this(new AmazonDynamoDBClient(region), true, config)
 {
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Constructs a DynamoDBContext object with the specified configuration.
 /// Uses a default AmazonDynamoDBClient as the client.
 /// </summary>
 /// <param name="config"></param>
 public DynamoDBContext(DynamoDBContextConfig config)
     : this(new AmazonDynamoDBClient(), config)
 {
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Constructs a DynamoDBContext object with the specified DynamoDB client
 /// and configuration.
 /// </summary>
 /// <param name="client">Client to use for making calls</param>
 /// <param name="config">Configuration to use</param>
 public DynamoDBContext(IAmazonDynamoDB client, DynamoDBContextConfig config)
     : this(client, false, config)
 {
 }
Ejemplo n.º 14
0
        public DynamoDBFlatConfig(DynamoDBOperationConfig operationConfig, DynamoDBContextConfig contextConfig)
        {
            if (operationConfig == null)
                operationConfig = _emptyOperationConfig;
            if (contextConfig == null)
                contextConfig = _emptyContextConfig;

            bool consistentRead = operationConfig.ConsistentRead ?? contextConfig.ConsistentRead ?? false;
            bool skipVersionCheck = operationConfig.SkipVersionCheck ?? contextConfig.SkipVersionCheck ?? false;
            bool ignoreNullValues = operationConfig.IgnoreNullValues ?? contextConfig.IgnoreNullValues ?? false;
            string overrideTableName =
                !string.IsNullOrEmpty(operationConfig.OverrideTableName) ? operationConfig.OverrideTableName : string.Empty;
            string tableNamePrefix =
                !string.IsNullOrEmpty(operationConfig.TableNamePrefix) ? operationConfig.TableNamePrefix :
                !string.IsNullOrEmpty(contextConfig.TableNamePrefix) ? contextConfig.TableNamePrefix : string.Empty;
            bool backwardQuery = operationConfig.BackwardQuery ?? false;
            string indexName =
                !string.IsNullOrEmpty(operationConfig.IndexName) ? operationConfig.IndexName : DefaultIndexName;
            List<ScanCondition> queryFilter = operationConfig.QueryFilter ?? new List<ScanCondition>();
            ConditionalOperatorValues conditionalOperator = operationConfig.ConditionalOperator;

            ConsistentRead = consistentRead;
            SkipVersionCheck = skipVersionCheck;
            IgnoreNullValues = ignoreNullValues;
            OverrideTableName = overrideTableName;
            TableNamePrefix = tableNamePrefix;
            BackwardQuery = backwardQuery;
            IndexName = indexName;
            QueryFilter = queryFilter;
            ConditionalOperator = conditionalOperator;
        }