コード例 #1
0
        public async Task <ItemResponse <T> > ReadCurrentAsync <T>(
            ConflictProperties cosmosConflict,
            PartitionKey partitionKey,
            ITrace trace,
            CancellationToken cancellationToken = default)
        {
            if (cosmosConflict == null)
            {
                throw new ArgumentNullException(nameof(cosmosConflict));
            }

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

            string containerResourceId = await this.container.GetCachedRIDAsync(
                forceRefresh : false,
                trace,
                cancellationToken : cancellationToken);

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

            string containerLink = this.ClientContext.CreateLink(
                parentLink: dbLink,
                uriPathSegment: Paths.CollectionsPathSegment,
                id: containerResourceId);

            string itemLink = this.ClientContext.CreateLink(
                parentLink: containerLink,
                uriPathSegment: Paths.DocumentsPathSegment,
                id: cosmosConflict.SourceResourceId);

            ResponseMessage response = await this.ClientContext.ProcessResourceOperationStreamAsync(
                resourceUri : itemLink,
                resourceType : ResourceType.Document,
                operationType : OperationType.Read,
                requestOptions : null,
                cosmosContainerCore : this.container,
                feedRange : new FeedRangePartitionKey(partitionKey),
                streamPayload : null,
                requestEnricher : null,
                trace : trace,
                cancellationToken : cancellationToken);

            return(this.ClientContext.ResponseFactory.CreateItemResponse <T>(response));
        }
コード例 #2
0
        public override async Task <ItemResponse <T> > ReadCurrentAsync <T>(
            ConflictProperties cosmosConflict,
            PartitionKey partitionKey,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            if (cosmosConflict == null)
            {
                throw new ArgumentNullException(nameof(cosmosConflict));
            }

            // SourceResourceId is RID based on Conflicts, so we need to obtain the db and container rid
            DatabaseInternal databaseCore       = (DatabaseInternal)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 <ResponseMessage> response = this.clientContext.ProcessResourceOperationStreamAsync(
                resourceUri: itemLink,
                resourceType: ResourceType.Document,
                operationType: OperationType.Read,
                requestOptions: null,
                cosmosContainerCore: this.container,
                partitionKey: partitionKey,
                streamPayload: null,
                requestEnricher: null,
                diagnosticsContext: null,
                cancellationToken: cancellationToken);

            return(await this.clientContext.ResponseFactory.CreateItemResponseAsync <T>(response));
        }