📜  c# cosmos db 将项目添加到容器中 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:08.899000             🧑  作者: Mango

代码示例1
using Microsoft.Azure.Cosmos

public class Test
{
    [JsonProperty(PropertyName = "CategoryId")]
    public int Id { get; set; }
}

public async Task AddItemsAsync(CosmosClient cosmosClient, Database database, Container container)
{

    Test test = new Test();
    test.Id = 0;

    ItemResponse testResponse = await container.CreateItemAsync(test, new PartitionKey(""));

    Console.WriteLine("Created item in database with id: {0} Operation consumed {1} RUs.\n"
        , testResponse.Resource.Id, testResponse.RequestCharge);
}