README.md
以下内容由 AI 翻译,如有问题请点此提交 issue 反馈
Microsoft Azure Cosmos DB .NET SDK 版本 3
此客户端库使客户端应用程序能够连接到 Azure Cosmos DB for NoSQL。Azure Cosmos DB 是一项全球分布式的多模型数据库服务。有关更多信息,请参阅 https://azure.microsoft.com/services/cosmos-db/。
CosmosClient client = new CosmosClient("https://mycosmosaccount.documents.azure.com:443/", "mysupersecretkey");
Database database = await client.CreateDatabaseIfNotExistsAsync("MyDatabaseName");
Container container = await database.CreateContainerIfNotExistsAsync(
"MyContainerName",
"/partitionKeyPath",
400);
// Create an item
dynamic testItem = new { id = "MyTestItemId", partitionKeyPath = "MyTestPkValue", details = "it's working", status = "done" };
ItemResponse<dynamic> createResponse = await container.CreateItemAsync(testItem);
// Query for an item
using (FeedIterator<dynamic> feedIterator = container.GetItemQueryIterator<dynamic>(
"select * from T where T.status = 'done'"))
{
while (feedIterator.HasMoreResults)
{
FeedResponse<dynamic> response = await feedIterator.ReadNextAsync();
foreach (var item in response)
{
Console.WriteLine(item);
}
}
}
通过 Nuget.org 安装
Install-Package Microsoft.Azure.Cosmos
有关可用版本,请参阅 SDK 版本管理。
有用的链接
- 入门 APP
- GitHub 示例
- SDK 最佳实践
- MultiMaster 示例
- Azure Cosmos DB 服务的资源模型
- Cosmos DB 资源 URI
- 分区
- Azure Cosmos DB for NoSQL 查询简介
- SDK API
- 使用模拟器
- 捕获跟踪
- 发布说明
- 诊断和故障排除
Microsoft 开源行为准则
本项目已采纳 Microsoft 开源行为准则。
资源:
贡献
有关向此仓库贡献的详细信息,请参阅 贡献指南。
本项目欢迎贡献和建议。 大多数贡献要求您同意 贡献者许可协议 (CLA),声明您有权并且确实授予我们 使用您贡献的权利。有关详细信息,请访问 https://cla.microsoft.com。
当您提交拉取请求时,CLA-bot 将自动确定您是否需要提供 CLA 并相应地标记 PR(例如,标签、评论)。只需按照 机器人提供的说明操作即可。您只需在所有使用我们 CLA 的仓库中执行一次此操作。
本项目已采纳 Microsoft 开源行为准则。 有关更多信息,请参阅 行为准则常见问题解答 或 就任何额外问题或意见联系 opencode@microsoft.com。