[英]cannot convert to microsoft.azure.cosmosDB.table.itableentity
I'm trying to insert some test values into an Azure table using storage connection string. 我正在尝试使用存储连接字符串将一些测试值插入到Azure表中。 When I tried to perform insert operation it showing error as cannot convert TableStorage.RunnerInputs to Microsoft.azure.cosmosDB.table.itableentity. 当我尝试执行插入操作时,它显示错误,因为无法将TableStorage.RunnerInputs转换为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 我正在通过参考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);
Runner class 跑步班
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? 谁能让我知道如何克服这个问题?
It seems that your problem is TableEntity package reference can not be matched with TableOperation package reference. 看来您的问题是TableEntity包引用无法与TableOperation包引用匹配。 The Azure Comos DB and Azure Table Storage are different tables. Azure Comos数据库和Azure表存储是不同的表。 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'). 您可以对这些类使用相同的程序包引用来解决您的问题(例如“ Microsoft.WindowsAzure.Storage.Table”)。
The result is like this: 结果是这样的:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.