【问题标题】:How to delete a Product如何删除产品
【发布时间】:2019-10-23 22:53:32
【问题描述】:

如何使用 asp.net core web api 删除以下查询。

查询:

Select * 
From catalog.Industy.Category.Subcategory.Product 
Where Product.Id="97c27069-4a16-44c3-bdf1-627c8ea339fa"

json 正文:

{
    "id": "9fc41e97-c32e-45e6-853f-ae7993cbc773",
    "Industy": {
        "Id": "40f5a6f5-2947-469c-8d29-6aa84de982cb",
        "Category": {
            "Subcategory": {     
                "Product": {
                    "Addons": {   
                    },
                    "MethodOfPreparation": {

                    }
                }
            }
        }
    }

【问题讨论】:

    标签: sql asp.net-core azure-cosmosdb


    【解决方案1】:

    也许你应该先阅读使用 CosmosDB 的文档: here

    在此页面上,您可以看到如何查询您的产品,然后从您的收藏中删除此记录:

     var query = client.CreateDocumentQuery<YourDocumentModel>(UriFactory.CreateDocumentCollectionUri(databaseName, collectionName),
     "<your sql>",
     queryOptions);
    

    使用此结果,您可以更新对象 (yourDocumentModelObject) 并从子类别中删除产品。 然后将其保存回集合中,执行以下操作:

    await client.UpsertDocumentAsync<YourDocumentModel>(UriFactory.CreateDocumentCollectionUri(databaseName, collectionName),
    yourDocumentModelObject);
    

    【讨论】:

      【解决方案2】:

      用cosmosdb sql api,应该是

       SELECT *
          FROM Products p
          WHERE p.Industy.Category.Subcategory.Product.Id = "97c27069-4a16-44c3-bdf1-627c8ea339fa"
      

      其中 Products 是容器的名称

      【讨论】:

      • 我的 json 主体看起来像上面。
      • 我写了一个查询文档。如何删除它。请有任何想法
      猜你喜欢
      • 1970-01-01
      • 2022-06-22
      • 2015-03-31
      • 1970-01-01
      • 2016-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多