第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使用 C# 和 cosmos 客戶端從 cosmos 數(shù)據(jù)庫(kù)中刪除文檔

使用 C# 和 cosmos 客戶端從 cosmos 數(shù)據(jù)庫(kù)中刪除文檔

C#
收到一只叮咚 2023-07-22 15:58:40
我是 Cosmos DB 的新手,在閱讀了 Microsoft 文檔后,我嘗試從 Cosmos db 中刪除記錄。我嘗試盡可能地遵循這個(gè)例子。正在找到并讀取記錄,但在嘗試刪除時(shí)遇到未找到錯(cuò)誤。該集合已分區(qū),并且我已經(jīng)在示例中提到了分區(qū)鍵,但仍然會(huì)導(dǎo)致錯(cuò)誤。    private async Task QueryItemsAsync()    {        var sqlQueryText = "SELECT * FROM c WHERE c.tenantId = '5c6cb2d77c1c2edc001b9007' and c.id = 'abae8abf-5836-464f-8129-1f0e83a1f639'";        QueryDefinition queryDefinition = new QueryDefinition(sqlQueryText);        FeedIterator<Order> queryResultSetIterator = this.container.GetItemQueryIterator<Order>(queryDefinition);        List<Order> orders = new List<Order>();        while (queryResultSetIterator.HasMoreResults)        {            FeedResponse<Order> currentResultSet = await queryResultSetIterator.ReadNextAsync();            foreach (Order o in currentResultSet)            {                orders.Add(o);                Console.WriteLine("\tRead {0}\n", o);                   }        }    }             private async Task DeleteFamilyItemAsync()    {        var partitionKeyValue = "tenantId";        var orderId = "abae8abf-5836-464f-8129-1f0e83a1f639";        // Delete an item. Note we must provide the partition key value and id of the item to delete        ItemResponse<Order> orderResponse = await this.container.DeleteItemAsync<Order>(orderId, new PartitionKey(partitionKeyValue));        Console.WriteLine("Deleted Family [{0},{1}]\n", partitionKeyValue, orderId);    }如下所示,正在讀取記錄,因此可以找到它,但是當(dāng)我嘗試刪除它時(shí),它沒有被刪除。讀取{“Id”:null,“patentId”:null,“orchestrationId”:null,“preOrderId”:“88557ec1-dccb-4397-9ce4-20b6aeb1d636”,“cartId”:“adc463ef-7f38-4fa8-8f37-e505db3a5134”,“confirmationNum”:“QDQ-9 244014-14708","cartConfirmationNum":"IBM-8622967-14079","countryCode":null,"type":"order","cancelDate":null,"id":"abae8abf-5836-464f-8129-1f0e83a1f639"}發(fā)生 NotFound 錯(cuò)誤:CosmosRequestException;StatusCode=NotFound;SubStatusCode=0;ActivityId=6dd52d23-68c8-4e6d-b4ff-70cd2a6921cf;RequestCharge=1.24;Message=響應(yīng)狀態(tài)代碼不表示成功:404 Substatus:0 原因:()。;演示結(jié)束,按任意鍵退出。
查看完整描述

1 回答

?
慕蓋茨4494581

TA貢獻(xiàn)1850條經(jīng)驗(yàn) 獲得超11個(gè)贊

問(wèn)題出在你的partitionKeyValue. 您提供的是分區(qū)鍵定義而不是值。該值是實(shí)際的租戶 id 而不是文本tenantId。


您的刪除代碼應(yīng)如下所示:


private async Task DeleteFamilyItemAsync()

{

    var partitionKeyValue = "5c6cb2d77c1c2edc001b9007"; // <-- This is the change

    var orderId = "abae8abf-5836-464f-8129-1f0e83a1f639";


    // Delete an item. Note we must provide the partition key value and id of the item to delete

    ItemResponse<Order> orderResponse = await this.container.DeleteItemAsync<Order>(orderId, new PartitionKey(partitionKeyValue));

    Console.WriteLine("Deleted Family [{0},{1}]\n", partitionKeyValue, orderId);

}


查看完整回答
反對(duì) 回復(fù) 2023-07-22
  • 1 回答
  • 0 關(guān)注
  • 147 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)