无法转换为microsoft.azure.cosmosDB.table.itableentity [英] cannot convert to microsoft.azure.cosmosDB.table.itableentity
问题描述
我正在尝试使用存储连接字符串将一些测试值插入到Azure表中.当我尝试执行插入操作时,它显示错误,因为无法将TableStorage.RunnerInputs转换为Microsoft.azure.cosmosDB.table.itableentity. 我正在通过引用 https://docs.microsoft.com/en-我们/azure/cosmos-db/table-storage-how-to-to-dotnet
I'm trying to insert some test values into an Azure table using storage connection string. When I tried to perform insert operation it showing error as cannot convert TableStorage.RunnerInputs to Microsoft.azure.cosmosDB.table.itableentity. I'm working on this with the reference to https://docs.microsoft.com/en-us/azure/cosmos-db/table-storage-how-to-use-dotnet
*
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));
//Create the table client.
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
//Create the CloudTable object that represents the "people" table.
CloudTable table = tableClient.GetTableReference("InputParameters");
table.CreateIfNotExists();
//Create a new customer entity.
RunnerInputs RunnerInput = new RunnerInputs("OnlyDate", "rowkey");
//CloudTable test = null;
RunnerInput.InputDate = "20180213";
//Inputvalue = "20180213";
//Create the TableOperation object that inserts the customer entity.
TableOperation insertOperation = TableOperation.Insert(RunnerInput);
//Execute the insert operation.
table.Execute(insertOperation);
亚军类
namespace TableStorage
{
public class RunnerInputs:TableEntity
{
public RunnerInputs(string ParameterName,string RowValue)
{
this.PartitionKey = ParameterName;
this.RowKey = RowValue;
}
public string InputDate { get; set; }
}
}
错误屏幕截图,以供参考.谁能让我知道如何克服这个问题?尝试通过强制转换值,但是结果是相同的.
Error Screenshot for reference. Can anyone let me know how can we overcome this? Have tried by casting the value, but the result is same.
推荐答案
任何人都可以让我知道我们如何克服这个问题吗?
Can anyone let me know how can we overcome this?
您的问题似乎是 TableEntity 包引用与 TableOperation 包引用不匹配. Azure Comos数据库和Azure表存储是不同的表.他们的包裹不能互相配合.您可以对这些类使用相同的包引用来解决您的问题(例如"Microsoft.WindowsAzure.Storage.Table").
结果是这样的:
It seems that your problem is TableEntity package reference can not be matched with TableOperation package reference. The Azure Comos DB and Azure Table Storage are different tables. Their packages don't work with each other. You could use the same package reference for these classes to solve your problem( like 'Microsoft.WindowsAzure.Storage.Table').
The result is like this:
这篇关于无法转换为microsoft.azure.cosmosDB.table.itableentity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!