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; ConsistentRead = consistentRead; SkipVersionCheck = skipVersionCheck; IgnoreNullValues = ignoreNullValues; OverrideTableName = overrideTableName; TableNamePrefix = tableNamePrefix; BackwardQuery = backwardQuery; }
public async Task GetDynamoDbUser(string environment, string email) { if (dynamoDbClient == null) { dynamoDbClient = new AmazonDynamoDBClient(); } DynamoDBContextConfig config = new DynamoDBContextConfig() { TableNamePrefix = environment + "-" }; DynamoDBContext context = new DynamoDBContext(dynamoDbClient, config); log = "Looking for user(" + email + ") within dynamodb table " + environment + "-User."; user = await context.LoadAsync <User>(email); if (user != null) { log += "*** Found that user ***"; } else { log += "*** Did not find that user"; } }
static AWSConfigsDynamoDB() { try { #if BCL || AWSSDK_UNITY var root = new RootConfig(); var section = root.GetServiceSection(dynamoDBKey); if (section == null) { return; } var rootSection = new DynamoDBSectionRoot(section); if (rootSection.DynamoDB != null) { AWSConfigsDynamoDB.Configure(rootSection.DynamoDB); } #endif } finally { // If no configuration exist at least // configure the context config to the default. if (Context == null) { Context = new DynamoDBContextConfig(); ConversionSchema = ConversionSchema.V1;; } } }
public static void ConfigureDynamoDb(this IServiceCollection services, bool isDebug) { var tableName = Environment.GetEnvironmentVariable("LinkTable"); AWSConfigsDynamoDB.Context.TypeMappings[typeof(LinkDto)] = new Amazon.Util.TypeMapping(typeof(LinkDto), tableName); var dbConfig = new AmazonDynamoDBConfig(); if (isDebug) { //TODO parametrize dbConfig = new AmazonDynamoDBConfig { RegionEndpoint = RegionEndpoint.APSoutheast2, ServiceURL = "http://localhost:8000" }; } var client = new AmazonDynamoDBClient(dbConfig); var config = new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2 }; var ddbContext = new DynamoDBContext(client, config); services.AddSingleton <IDynamoDBContext>(ddbContext); }
public async Task SaveAsync(User userProperties) { userProperties.Tags = CleanTags(userProperties.Tags); CleanFieldDescriptors(userProperties.FieldDescriptors); try { var config = new DynamoDBContextConfig { TableNamePrefix = TablePrefix }; var context = new DynamoDBContext(Client, config); await context.SaveAsync(userProperties); } catch (ProvisionedThroughputExceededException ex) { _logger.LogError("ProvisionedThroughputExceededException writing user properties to DynamoDB: " + ex.Message); throw; } catch (ConditionalCheckFailedException ex) { _logger.LogError("Conditional check failed for save user properties: " + userProperties.UserId); throw; } catch (Exception ex) { _logger.LogError(ex, "Exception writing user properties to DynamoDB: " + ex.Message); throw; } }
public async Task <User> LoadAsync(Guid accountId, Guid userId) { var stopwatch = Stopwatch.StartNew(); try { var config = new DynamoDBContextConfig { TableNamePrefix = TablePrefix, }; var context = new DynamoDBContext(Client, config); return(await context.LoadAsync <User>(accountId, userId)); } catch (ProvisionedThroughputExceededException ex) { _logger.LogError(ex, "ProvisionedThroughputExceededException LoadAsync for user properties from DynamoDB: " + ex.Message); throw; } catch (Exception ex) { _logger.LogError(ex, "Exception loading user properties by Id: " + ex); throw; } finally { stopwatch.Stop(); _logger.LogInformation("Load user properties by Id took: {0}ms for {1}", stopwatch.ElapsedMilliseconds, userId); } }
public void Save(Checkpoint checkpoint) { try { var config = new DynamoDBContextConfig { TableNamePrefix = TablePrefix, SkipVersionCheck = true }; var context = new DynamoDBContext(Client, config); _logger.LogTrace("Saving checkpoint: {0}", checkpoint); context.SaveAsync(checkpoint); } catch (ProvisionedThroughputExceededException ex) { _logger.LogError(ex, "ProvisionedThroughputExceededException writing measurement to DynamoDB: " + ex.Message); throw; } catch (ConditionalCheckFailedException ex) { _logger.LogError(ex, "Conditional check failed for save measurement - ignoring"); // Safe to ignore as measurement is not likely to be being updated. } catch (Exception ex) { _logger.LogError(ex, "Exception writing measurement to DynamoDB: " + ex.Message); throw; } }
public static IServiceCollection AddDynamoDb(this IServiceCollection services) { // ReSharper disable once InconsistentNaming const string TABLENAME_ENVIRONMENT_VARIABLE_LOOKUP = "RidesTable"; // Check to see if a table name was passed in through environment variables and if so // add the table mapping. var tableName = Environment.GetEnvironmentVariable(TABLENAME_ENVIRONMENT_VARIABLE_LOOKUP); if (!string.IsNullOrEmpty(tableName)) { AWSConfigsDynamoDB.Context.TypeMappings[typeof(Ride)] = new Amazon.Util.TypeMapping(typeof(Ride), tableName); } services.AddSingleton <IAmazonDynamoDB, AmazonDynamoDBClient>(); services.AddSingleton(sp => new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2 }); var config = new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2 }; // TODO: singleton ?? services.AddTransient <IDynamoDBContext>(sp => new DynamoDBContext(new AmazonDynamoDBClient(), config)); return(services); }
public override void LoadUnitTestData(DataContainer dataContainer) { Console.WriteLine($"Using connection string {dataContainer.ConnectionString}"); using (var client = new DynamoDBClientBuilder(dataContainer.ConnectionString).GetClient()) { client.CreateTableAsync("CONTACTS_AUDIT", new List <KeySchemaElement>() { new KeySchemaElement("ID", KeyType.HASH) }, new List <AttributeDefinition>() { new AttributeDefinition("ID", ScalarAttributeType.S) }, new ProvisionedThroughput(10, 10) ).Wait(); client.CreateTableAsync("EMAILS", new List <KeySchemaElement>() { new KeySchemaElement("ID", KeyType.HASH) }, new List <AttributeDefinition>() { new AttributeDefinition("ID", ScalarAttributeType.S) }, new ProvisionedThroughput(10, 10) ).Wait(); client.CreateTableAsync("LEADS", new List <KeySchemaElement>() { new KeySchemaElement("ID", KeyType.HASH) }, new List <AttributeDefinition>() { new AttributeDefinition("ID", ScalarAttributeType.S) }, new ProvisionedThroughput(10, 10) ).Wait(); client.CreateTableAsync("PEOPLE", new List <KeySchemaElement>() { new KeySchemaElement("Id", KeyType.HASH) }, new List <AttributeDefinition>() { new AttributeDefinition("Id", ScalarAttributeType.S) }, new ProvisionedThroughput(10, 10) ).Wait(); var contextConfig = new DynamoDBContextConfig() { TableNamePrefix = "" }; var context = new DynamoDBContext(client, contextConfig); var people = GetPeople(200); var contactsBatch = context.CreateBatchWrite <Person>(); contactsBatch.AddPutItems(people); contactsBatch.ExecuteAsync().GetAwaiter().GetResult(); } }
private static DynamoDBContext GetContext() { AWSCredentials credentials = new StoredProfileAWSCredentials("rli-dev", "C:/Users/pnpham/.aws/credentials"); var Client = new AmazonDynamoDBClient(credentials, Amazon.RegionEndpoint.USEast1); var contextConfig = new DynamoDBContextConfig(); return(new DynamoDBContext(Client, contextConfig)); }
public static IDynamoDBContext GetDbContext() { var config = new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2 }; return(new DynamoDBContext(new AmazonDynamoDBClient(Environment.AccessKey, Environment.SecretKey), config)); }
protected void InitRepository() { var config = new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2 }; AWSConfigsDynamoDB.Context.TypeMappings[typeof(T)] = new Amazon.Util.TypeMapping(typeof(T), DynamoTableName); DDBContext = new DynamoDBContext(new AmazonDynamoDBClient(), config); }
public DynamoCrudRepository() { var config = new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2 }; client = new AmazonDynamoDBClient(); dbContext = new DynamoDBContext(client, config); }
/// <summary> /// Default constructor that Lambda will invoke. /// </summary> public ShoppingCartRepository() { AWSConfigsDynamoDB.Context.TypeMappings[typeof(Item)] = new Amazon.Util.TypeMapping(typeof(Item), TABLENAME); var config = new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2 }; this._dDBContext = new DynamoDBContext(new AmazonDynamoDBClient(), config); }
public DataService() { AWSConfigsDynamoDB.Context.TypeMappings[typeof(Todo)] = new Amazon.Util.TypeMapping(typeof(Todo), "todo"); Config = new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2 }; Context = new DynamoDBContext(new AmazonDynamoDBClient(RegionEndpoint.EUWest1), Config); }
public BlogsController(IAmazonDynamoDB dynamoDb, ILogger <BlogsController> logger) { var config = new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2 }; this.context = new DynamoDBContext(dynamoDb, config); this.logger = logger; }
public void SetContext() { DynamoDBContextConfig config = new DynamoDBContextConfig() { TableNamePrefix = SkillMetadata.DbTablePrefix }; DbContext = new DynamoDBContext(Client, config); }
public ClientService(IDynamoDBSettings settings) { _dynamoDBClient = new AmazonDynamoDBClient(RegionEndpoint.USEast2); var config = new DynamoDBContextConfig { TableNamePrefix = settings.Prefix }; _context = new DynamoDBContext(_dynamoDBClient, config); }
/// <summary> /// Default constructor that Lambda will invoke. /// </summary> public Functions() { ApiDefine.Initialize(); var config = new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2 }; this.DDBContext = new DynamoDBContext(new AmazonDynamoDBClient(), config); }
public GetTodo() { AWSConfigsDynamoDB.Context.TypeMappings[typeof(TodoItem)] = new Amazon.Util.TypeMapping(typeof(TodoItem), Functions.Table); var config = new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2 }; _dbContext = new DynamoDBContext(new AmazonDynamoDBClient(), config); }
///<SUMMMARY> /// A Function that will load customer database ///</----> public void LoadDatabase() { AWSConfigsDynamoDB.Context.TypeMappings[typeof(Customers)] = new Amazon.Util.TypeMapping(typeof(Customers), "MaoProduce-Stack-CustomerTable-OZ2X2B0G09V6"); var config = new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2 }; this.DDBContext2 = new DynamoDBContext(new AmazonDynamoDBClient(), config); }
public DbDataService(IAmazonDynamoDB dynamoDbClient) { AWSConfigsDynamoDB.Context.TypeMappings[typeof(T)] = new Amazon.Util.TypeMapping(typeof(T), typeof(T).Name); var conf = new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2 }; _ddbContext = new DynamoDBContext(dynamoDbClient, conf); }
// Constructor used for testing public ServerlessHelloWorld(IAmazonDynamoDB client) { AWSConfigsDynamoDB.Context.TypeMappings[typeof(Greeting)] = new Amazon.Util.TypeMapping(typeof(Greeting), GREETINGS_TABLE_NAME); var config = new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2 }; this.dbContext = new DynamoDBContext(client, config); }
public AttractionRepository() { AWSConfigsDynamoDB.Context.TypeMappings[typeof(Attraction)] = new Amazon.Util.TypeMapping(typeof(Attraction), TableName); var config = new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2 }; _dbContext = new DynamoDBContext(new AmazonDynamoDBClient(RegionEndpoint.USWest2), config); }
public DynamoDBContext GetContext(string connectionString) { var contextConfig = new DynamoDBContextConfig() { TableNamePrefix = "" }; var context = new DynamoDBContext(GetClient(), contextConfig); return(context); }
public TODOListDataAccess(IAmazonDynamoDB ddbClient) { var config = new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2, ConsistentRead = true }; this.Context = new DynamoDBContext(ddbClient); }
public DynamoService() { _client = new AmazonDynamoDBClient(); _conf = new DynamoDBContextConfig { ConsistentRead = true, Conversion = DynamoDBEntryConversion.V2 }; }
public void CreateContext(DynamoDBEntryConversion conversion) { var config = new DynamoDBContextConfig { //IgnoreNullValues = true Conversion = conversion }; Context = new DynamoDBContext(Client, config); }
public DynamoDbCityService(string environment) { this.environment = environment; DynamoDBContextConfig config = new DynamoDBContextConfig() { TableNamePrefix = environment + "-" }; dynamoDbContext = new DynamoDBContext(DynamoDbClientService.getDynamoDBClient(environment), config); tableName = environment + "-City"; }
public DynamoDbService(IAmazonDynamoDB ddbClient) { MapEntities(); var config = new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2 }; _ddbContext = new DynamoDBContext(ddbClient, config); }
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; DynamoDBEntryConversion conversion = operationConfig.Conversion ?? contextConfig.Conversion ?? DynamoDBEntryConversion.CurrentConversion; ConsistentRead = consistentRead; SkipVersionCheck = skipVersionCheck; IgnoreNullValues = ignoreNullValues; OverrideTableName = overrideTableName; TableNamePrefix = tableNamePrefix; BackwardQuery = backwardQuery; IndexName = indexName; QueryFilter = queryFilter; ConditionalOperator = conditionalOperator; Conversion = conversion; State = new OperationState(); }
internal DynamoDBConfig() { Context = new DynamoDBContextConfig(); ConversionSchema = ConversionSchema.V1; }