コード例 #1
0
 internal CosmosContainersCore(
     CosmosClientContext clientContext,
     CosmosDatabaseCore database)
 {
     this.database       = database;
     this.clientContext  = clientContext;
     this.containerCache = new ConcurrentDictionary <string, CosmosContainer>();
 }
コード例 #2
0
        public override async Task <ItemResponse <T> > ReadCurrentAsync <T>(
            PartitionKey partitionKey,
            CosmosConflictSettings cosmosConflict,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            if (partitionKey == null)
            {
                throw new ArgumentNullException(nameof(partitionKey));
            }

            if (cosmosConflict == null)
            {
                throw new ArgumentNullException(nameof(cosmosConflict));
            }

            // SourceResourceId is RID based on Conflicts, so we need to obtain the db and container rid
            CosmosDatabaseCore databaseCore       = (CosmosDatabaseCore)this.container.Database;
            string             databaseResourceId = await databaseCore.GetRIDAsync(cancellationToken);

            string containerResourceId = await this.container.GetRIDAsync(cancellationToken);

            Uri dbLink = this.clientContext.CreateLink(
                parentLink: string.Empty,
                uriPathSegment: Paths.DatabasesPathSegment,
                id: databaseResourceId);

            Uri containerLink = this.clientContext.CreateLink(
                parentLink: dbLink.OriginalString,
                uriPathSegment: Paths.CollectionsPathSegment,
                id: containerResourceId);

            Uri itemLink = this.clientContext.CreateLink(
                parentLink: containerLink.OriginalString,
                uriPathSegment: Paths.DocumentsPathSegment,
                id: cosmosConflict.SourceResourceId);

            Task <CosmosResponseMessage> response = this.clientContext.ProcessResourceOperationStreamAsync(
                resourceUri: itemLink,
                resourceType: ResourceType.Document,
                operationType: OperationType.Read,
                requestOptions: null,
                cosmosContainerCore: this.container,
                partitionKey: partitionKey,
                streamPayload: null,
                requestEnricher: null,
                cancellationToken: cancellationToken);

            return(await this.clientContext.ResponseFactory.CreateItemResponseAsync <T>(response));
        }
コード例 #3
0
        internal CosmosContainerCore(
            CosmosClientContext clientContext,
            CosmosDatabaseCore database,
            string containerId)
        {
            this.Id            = containerId;
            this.ClientContext = clientContext;
            this.LinkUri       = clientContext.CreateLink(
                parentLink: database.LinkUri.OriginalString,
                uriPathSegment: Paths.CollectionsPathSegment,
                id: containerId);

            this.Database  = database;
            this.conflicts = new CosmosConflictsCore(this.ClientContext, this);
            this.cachedUriSegmentWithoutId = this.GetResourceSegmentUriWithoutId();
            this.queryClient = queryClient ?? new CosmosQueryClientCore(this.ClientContext, this);
        }
コード例 #4
0
        internal CosmosContainerCore(
            CosmosClientContext clientContext,
            CosmosDatabaseCore database,
            string containerId)
        {
            this.Id            = containerId;
            this.ClientContext = clientContext;
            this.LinkUri       = clientContext.CreateLink(
                parentLink: database.LinkUri.OriginalString,
                uriPathSegment: Paths.CollectionsPathSegment,
                id: containerId);

            this.Database             = database;
            this.Items                = new CosmosItemsCore(this.ClientContext, this);
            this.StoredProcedures     = new CosmosStoredProceduresCore(this.ClientContext, this);
            this.Triggers             = new CosmosTriggers(this.ClientContext, this);
            this.UserDefinedFunctions = new CosmosUserDefinedFunctions(this.ClientContext, this);
        }