问题描述
您好,感谢您提供的所有帮助! 我在更新我的天蓝色表时遇到问题,我不确定该怎么办 我在做什么: 1,将json解析为var 2.使用另一个创建该变量的实例测试= parsedJson.latest; 3.在表操作中使用该var(自动分配的字符串)来插入或替换表实体。使用的代码如下:
$settings = [System.Xml.XmlWriterSettings]@{
Encoding = $encoding
Indent = $true
NewLineOnAttributes = $true
}
$writer = [System.Xml.XmlWriter]::Create($filename,$settings)
# <?xml version="1.0" encoding="utf-8"?>
# <Config>
# <Group
# name="PropertyGroup">
# <Property
# id="1"
# value="Foo" />
# <Property
# id="2"
# value="Bar"
# exclude="false" />
# </Group>
# </Config>
响应:参数1:无法将'string'转换为'Microsoft.WindowsAzure.Storage.Table.ITableEntity'
解决方法
在TableOperation.insertOrMerge(TableEntity实体)方法中,对象实例实现TableEntity
与操作关联。
首先,您需要像下面这样的TableEntity
:
public class DashboardApple : TableEntity
{
public string Latest{ get; set; }
public int ApplesCount { get; set; }
}
然后实例化表实体。
var dashboardApple = new DashboardApple
{
PartitionKey = "myPartition",RowKey = "myRow",Latest= "GoldenDelicious",ApplesCount = 5
};
最后,将表象信息发送到InsertOrMerge
。
TableOperation tableOperation = TableOperation.InsertOrMerge(dashboardApple);
根据您的情况,您可以设置Latest= o365Subnet.latest;
有关更多详细信息,请参阅此article。