C# 在Visual Studio Mac中找不到命名空间Microsoft.Azure
我正在尝试创建一个简单的DocumentDb hello world程序,得到的C# 在Visual Studio Mac中找不到命名空间Microsoft.Azure,c#,.net,azure,xamarin-studio,visual-studio-mac,C#,.net,Azure,Xamarin Studio,Visual Studio Mac,我正在尝试创建一个简单的DocumentDb hello world程序,得到的类型或命名空间名称“Azure”在命名空间“Microsoft”中不存在 使用Microsoft.Azure 我通过Nuget添加了DocumentDb库。在添加nuget包之后,是否需要手动添加对它的引用?我认为使用nuget会自动添加项目引用。根据您的另一个建议,似乎您使用的不是项目 NET Framework提供了一个全面的编程模型,用于在Windows上构建各种应用程序,从移动到web再到桌面 请尝试创建一个
类型或命名空间名称“Azure”在命名空间“Microsoft”中不存在
使用Microsoft.Azure
我通过Nuget添加了DocumentDb库。在添加nuget包之后,是否需要手动添加对它的引用?我认为使用nuget会自动添加项目引用。根据您的另一个建议,似乎您使用的不是项目
NET Framework提供了一个全面的编程模型,用于在Windows上构建各种应用程序,从移动到web再到桌面
请尝试创建一个.net核心项目。
我们可以从努吉那里得到消息。我使用.net core项目在windows平台上测试创建文档。对我来说,它工作正常。我想它也应该在Mac上工作。下面是我的演示代码
var endpointUrl = "https://documentdbnamespace.documents.azure.com:443/";
var authorizationKey = "xxxxxxxxxx";
var databaseId = "database";
var collectionId = "collection"; //I use an existing collect
using (_client = new DocumentClient(new Uri(endpointUrl), authorizationKey))
{
var collectionLink = UriFactory.CreateDocumentCollectionUri(databaseId, collectionId);
var product = new Product
{
Id= Guid.NewGuid().ToString(),
ProductId = "test"
};
Document created = _client.CreateDocumentAsync(collectionLink, product).Result;
}
Product.cs类别:
public class Product
{
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }
// used to set expiration policy
[JsonProperty(PropertyName = "ttl", NullValueHandling = NullValueHandling.Ignore)]
public int? TimeToLive { get; set; }
public string ProductId { get; set; }
public DateTime DateStarted { get; set; }
}
我们还可以从中获得更多文档示例代码。根据您的另一个,您似乎使用了not项目
NET Framework提供了一个全面的编程模型,用于在Windows上构建各种应用程序,从移动到web再到桌面
请尝试创建一个.net核心项目。
我们可以从努吉那里得到消息。我使用.net core项目在windows平台上测试创建文档。对我来说,它工作正常。我想它也应该在Mac上工作。下面是我的演示代码
var endpointUrl = "https://documentdbnamespace.documents.azure.com:443/";
var authorizationKey = "xxxxxxxxxx";
var databaseId = "database";
var collectionId = "collection"; //I use an existing collect
using (_client = new DocumentClient(new Uri(endpointUrl), authorizationKey))
{
var collectionLink = UriFactory.CreateDocumentCollectionUri(databaseId, collectionId);
var product = new Product
{
Id= Guid.NewGuid().ToString(),
ProductId = "test"
};
Document created = _client.CreateDocumentAsync(collectionLink, product).Result;
}
Product.cs类别:
public class Product
{
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }
// used to set expiration policy
[JsonProperty(PropertyName = "ttl", NullValueHandling = NullValueHandling.Ignore)]
public int? TimeToLive { get; set; }
public string ProductId { get; set; }
public DateTime DateStarted { get; set; }
}
我们还可以从中获得更多文档示例代码