internal DocumentClient BindForClient(DocumentDBAttribute attribute) { string resolvedConnectionString = ResolveConnectionString(attribute.ConnectionStringSetting); IDocumentDBService service = GetService(resolvedConnectionString); return(service.GetClient()); }
private static DocumentDBContext CreateContext(IDocumentDBService service) { return(new DocumentDBContext { Service = service, ResolvedDatabaseName = DatabaseName, ResolvedCollectionName = CollectionName }); }
internal static async Task <Database> CreateDatabaseIfNotExistsAsync(IDocumentDBService service, string databaseName) { Uri databaseUri = UriFactory.CreateDatabaseUri(databaseName); Database database = service.CreateDatabaseQuery().Where(db => db.Id == databaseName).AsEnumerable().FirstOrDefault(); if (database == null) { database = await service.CreateDatabaseAsync(new Database { Id = databaseName }); } return(database); }
public DocumentClient Convert(DocumentDBAttribute attribute) { if (attribute == null) { throw new ArgumentNullException(nameof(attribute)); } string resolvedConnectionString = _config.ResolveConnectionString(attribute.ConnectionStringSetting); IDocumentDBService service = _config.GetService(resolvedConnectionString); return(service.GetClient()); }
internal DocumentDBContext CreateContext(DocumentDBAttribute attribute, TraceWriter trace) { string resolvedConnectionString = ResolveConnectionString(attribute.ConnectionStringSetting); IDocumentDBService service = GetService(resolvedConnectionString); return(new DocumentDBContext { Service = service, Trace = trace, ResolvedAttribute = attribute }); }
private static DocumentDBContext CreateContext(IDocumentDBService service, bool createIfNotExists = false, string partitionKeyPath = null, int throughput = 0) { DocumentDBAttribute attribute = new DocumentDBAttribute(DatabaseName, CollectionName) { CreateIfNotExists = createIfNotExists, PartitionKey = partitionKeyPath, CollectionThroughput = throughput }; return(new DocumentDBContext { Service = service, ResolvedAttribute = attribute }); }
public static async Task CreateIfNotExistAsync(IDocumentDBService service, string databaseName, string documentCollectionName) { Uri databaseUri = UriFactory.CreateDatabaseUri(databaseName); Database database = new Database { Id = databaseName }; DocumentCollection documentCollection = new DocumentCollection { Id = documentCollectionName }; // If we queried for the Database or Collection before creation, we may hit a race condition // if multiple instances are running the same code. So let's just create and ignore a Conflict. await DocumentDBUtility.ExecuteAndIgnoreStatusCodeAsync(HttpStatusCode.Conflict, () => service.CreateDatabaseAsync(database)); await DocumentDBUtility.ExecuteAndIgnoreStatusCodeAsync(HttpStatusCode.Conflict, () => service.CreateDocumentCollectionAsync(databaseUri, documentCollection)); }
public TestDocumentDBServiceFactory(IDocumentDBService service) { _service = service; }
public TodoItemManager(IDocumentDBService service) { documentDBService = service; }
public UserService(IDocumentDBService cosmosDBService) { _cosmosDBService = cosmosDBService; }
public TripsManager(IDocumentDBService service) { documentDBService = service; }
public ProductController(ILogger <ProductController> logger, IDocumentDBService docService, IBlobService blobStorageService) { _logger = logger; _blobStorageService = blobStorageService; _docService = docService; }
public LoginItemManager(IDocumentDBService service) { documentDBService = service; }
internal static async Task <DocumentCollection> CreateDocumentCollectionIfNotExistsAsync(IDocumentDBService service, string databaseName, string collectionName, string partitionKey, int throughput) { Uri databaseUri = UriFactory.CreateDatabaseUri(databaseName); DocumentCollection collection = service.CreateDocumentCollectionQuery(databaseUri).Where(c => c.Id == collectionName).AsEnumerable().FirstOrDefault(); if (collection == null) { DocumentCollection documentCollection = new DocumentCollection { Id = collectionName }; if (!string.IsNullOrEmpty(partitionKey)) { documentCollection.PartitionKey.Paths.Add(partitionKey); } // If there is any throughput specified, pass it on. DocumentClient will throw with a // descriptive message if the value does not meet the collection requirements. RequestOptions collectionOptions = null; if (throughput != 0) { collectionOptions = new RequestOptions { OfferThroughput = throughput }; } collection = await service.CreateDocumentCollectionAsync(databaseUri, documentCollection, collectionOptions); } return(collection); }
public StoreInfoManager(IDocumentDBService service) { documentDBService = service; }
public ProductController(IDocumentDBService documentDBService, IBlobService blobStorageService) { docService = documentDBService; blobService = blobStorageService; }
public DocumentDBController(IDocumentDBService dbService) { this.dbService = dbService; }