简体   繁体   English

如何将字符串转换为 Microsoft.WindowsAzure.Storage.Table.ITableEntity?

[英]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.

相关问题 没有来自的装箱转换或类型参数转换 <T> 到&#39;Microsoft.WindowsAzure.Storage.Table.ITableEntity&#39; - There is no boxing conversion or type parameter conversion from <T> to 'Microsoft.WindowsAzure.Storage.Table.ITableEntity' 无法转换为microsoft.azure.cosmosDB.table.itableentity - cannot convert to microsoft.azure.cosmosDB.table.itableentity 如何判断Microsoft.WindowsAzure.Storage.DataMovement.TransferManager的CopyDirectoryAsync完成了? - How can I tell when CopyDirectoryAsync from Microsoft.WindowsAzure.Storage.DataMovement.TransferManager has finished? Microsoft.WindowsAzure.Storage.Table.TableEntity未标记为可序列化 - Microsoft.WindowsAzure.Storage.Table.TableEntity is not marked as serializable Microsoft.WindowsAzure.Storage 是否符合 FIPS 140-2 - Can Microsoft.WindowsAzure.Storage be FIPS 140-2 compliant 如何用 Microsoft.Azure.Storage.Blob 替换 Microsoft.WindowsAzure.Storage - How to replace Microsoft.WindowsAzure.Storage with Microsoft.Azure.Storage.Blob Microsoft.Azure.Cosmos.Table 和 Microsoft.WindowsAzure.Storage 之间的 ExecuteQuerySegmentedAsync 性能显着下降 - Significant performance degration on ExecuteQuerySegmentedAsync between Microsoft.Azure.Cosmos.Table and Microsoft.WindowsAzure.Storage Azure 表存储 - 用于扩展 ITableEntity 的任何类型的通用下载 - Azure Table Storage - Generic download for any type extending ITableEntity Azure function,缺少 Microsoft.WindowsAzure.Storage - Azure function, Microsoft.WindowsAzure.Storage missing 如何在Visual Studio 2013中安装WindowsAzure.Storage? - How do I install WindowsAzure.Storage in Visual Studio 2013?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM