[英]How can i convert a string to Microsoft.WindowsAzure.Storage.Table.ITableEntity?
Hi thanks in advance for all the help: I'm having a problem updating my azure table and i'm not sure what to do what im doing.您好,在此先感谢您提供的所有帮助:我在更新我的 azure 表时遇到问题,我不确定我正在做什么。 1.Parsing a json to a var 2.creating an instance of that var with another eg test = parsedJson;latest.
1.将 json 解析为 var 2.使用另一个 eg test = parsedJson;latest 创建该 var 的实例。 3. using that var (auto assigned string) with a table operation to insert or replace a table entity: The code used is below:
3. 使用带有表操作的 var(自动分配的字符串)来插入或替换表实体:使用的代码如下:
var o365Subnet = JsonConvert.DeserializeObject<ConvertJson>(o365Latest);
var o365Final = o365Subnet.latest;
TableOperation tableOperation = TableOperation.InsertOrMerge(o365Subnet.latest);
Response: Argument 1: Cannot convert 'string' to 'Microsoft.WindowsAzure.Storage.Table.ITableEntity'响应:参数 1:无法将“字符串”转换为“Microsoft.WindowsAzure.Storage.Table.ITableEntity”
In TableOperation.insertOrMerge(TableEntity entity) Method, the object instance implementing TableEntity
to associate with the operation.在 TableOperation.insertOrMerge(TableEntity entity) 方法中,实现 TableEntity 的
TableEntity
实例与操作关联。
First, you need have a TableEntity
like below:首先,您需要有一个如下所示的
TableEntity
:
public class DashboardApple : TableEntity
{
public string Latest{ get; set; }
public int ApplesCount { get; set; }
}
Then instantiate the table entity.然后实例化表实体。
var dashboardApple = new DashboardApple
{
PartitionKey = "myPartition",
RowKey = "myRow",
Latest= "GoldenDelicious",
ApplesCount = 5
};
Finally, send the tableentity to InsertOrMerge
.最后,将 tableentity 发送到
InsertOrMerge
。
TableOperation tableOperation = TableOperation.InsertOrMerge(dashboardApple);
According to your situation, you can set Latest= o365Su.net.latest;
根据你的情况,可以设置
Latest= o365Su.net.latest;
For more details, you could refer to this article .有关更多详细信息,您可以参考这篇文章。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.