public CosmosDbBuilder WithDatabaseThroughput(int throughput) { _dbconfig = _dbconfig != null ? new CosmosDbConfig(_dbconfig.DatabaseId, throughput) : new CosmosDbConfig(null, throughput); return(this); }
public CosmosDbClient( IServiceProvider serviceProvider, CosmosDbConnection connection, CosmosDbConfig dbConfig, IEnumerable <ContainerDefinition> containerDefinitions) { this.ServiceProvider = serviceProvider; IEnumerable <ContainerDefinition> definitions = containerDefinitions as ContainerDefinition[] ?? containerDefinitions.ToArray(); _containerDefinitions = definitions.ToArray(); _sdkClient = new CosmosClient( connection.EndPoint, connection.AuthKey, new CosmosClientOptions() { ConnectionMode = ConnectionMode.Direct, SerializerOptions = new CosmosSerializationOptions() { IgnoreNullValues = true, PropertyNamingPolicy = CosmosPropertyNamingPolicy.CamelCase } }); _lazyDatabase = new AsyncLazy <Database>(async() => { DatabaseResponse resp = await _sdkClient.CreateDatabaseIfNotExistsAsync(dbConfig.DatabaseId, dbConfig.Throughput); foreach (ContainerDefinition containerDefinition in definitions) { await Internal_EnsureContainerExists(resp.Database, containerDefinition); } return(resp.Database); }); }
public CosmosDbClient( CosmosDbConnectionSettings connectionSettings, CosmosDbConfig dbConfig, IEnumerable <ContainerDefinition> containerDefinitions) { IEnumerable <ContainerDefinition> definitions = containerDefinitions as ContainerDefinition[] ?? containerDefinitions.ToArray(); _containerDefinitions = definitions.ToArray(); _sdkClient = new CosmosClient( connectionSettings.EndPoint, connectionSettings.AuthKey, new CosmosClientOptions() { Serializer = new ConfigurableCosmosSerializer( new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, TypeNameHandling = TypeNameHandling.All, MissingMemberHandling = MissingMemberHandling.Ignore }), ConnectionMode = ConnectionMode.Direct }); _lazyDatabase = new AsyncLazy <Database>(async() => { DatabaseResponse resp = await _sdkClient.CreateDatabaseIfNotExistsAsync(dbConfig.DatabaseId, dbConfig.Throughput); foreach (ContainerDefinition containerDefinition in definitions) { await Internal_EnsureContainerExists(resp.Database, containerDefinition); } return(resp.Database); }); }
public CosmosDbClientBuilder WithDbConfig(CosmosDbConfig config) { _dbconfig = config; return(this); }
public CosmosDbClientBuilder ReadConfiguration(IConfiguration config) { _connectionSettings = new CosmosDbConnectionSettings(config); _dbconfig = new CosmosDbConfig(config); return(this); }
public CosmosDbBuilder UseDatabase(string databaseId) { _dbconfig = new CosmosDbConfig(databaseId, null); return(this); }
public CosmosDbBuilder ReadConfiguration(IConfiguration config) { _connection = new CosmosDbConnection(config); _dbconfig = new CosmosDbConfig(config); return(this); }