动态性类别的相关性是什么?

发布于 2025-02-06 04:05:10 字数 2616 浏览 1 评论 0 原文

  • 我正在从 microsoft.windowsazure.storage.torage.table in 我可以看到,在我的项目中使用了 DynamiCtientity 的某些地方。

  • 但是 dynamixtientity azure.data.data.tables nuget软件包中不存在。


  • tableentity dynamictentity

    之间是否有区别
  • 我读了文章,但仍然不了解相关性: azure.data.tables v12 v12在 azure.data下没有类 dynamictableity 。表

  • 我可以使用任何等效类用于迁移吗?


  • Is there a difference between TableEntity and DynamicTableEntity?

  • I read articles but still don't understand the relevance: Azure.Data.Tables v12 doesn't have a class DynamicTableEntity under Azure.Data.Tables.

  • Is there any equivalent class that I can use for the same for the migration?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

画中仙 2025-02-13 04:05:10

我的代码正面临同样的问题。在阅读Microsoft文档时,我发现了 tableentity 类型的描述。 azure.data.tables tableentity 类是:

一种通用词典样iTableIntity类型,该类型将实体上的一组任意属性定义为键值对。

这似乎是动态性的替代品。此外,它实现了:

itableIntity,iCollection< keyvaluepair< string,对象> gt; keyvaluepair< tkey< tkey,tvalue>>> gt; gt; gt; ,, aluepair< tkey ,TValue>>,iEnumerable,iEnumerable

,它具有类型的转换助手方法,可以代替以前的 EntityProperty 助手方法。

https:https://学习。 microsoft.com/en-us/dotnet/api/azure.data.table.tables.tableentity?view= azure-dotnet

I am facing the same issue with my code. While reading the Microsoft docs, I found this description of the TableEntity type. The Azure.Data.Tables TableEntity class is:

A generic dictionary-like ITableEntity type which defines an arbitrary set of properties on an entity as key-value pairs.

This appears to be the replacement for DynamicTableEntity. Furthermore, it implements:

ITableEntity, ICollection<KeyValuePair<String,Object>>, ICollection<KeyValuePair<TKey,TValue>>, IDictionary<String,Object>, IEnumerable<KeyValuePair<String,Object>>, IEnumerable<KeyValuePair<TKey,TValue>>, IEnumerable, IEnumerable

Also, it has type conversion helper methods that can be used in place of the former EntityProperty helper methods.

https://learn.microsoft.com/en-us/dotnet/api/azure.data.tables.tableentity?view=azure-dotnet

后知后觉 2025-02-13 04:05:10

对于以后击中的任何人。这是属性更新的示例
azure.data.table世界。

        public async Task<bool> UpdateField<V>(string partitionKey, string rowKey, string fieldName, V entityProperty)
        {
            var dynamicEntity = new TableEntity
            {
                PartitionKey = partitionKey,
                RowKey = rowKey
            };
            dynamicEntity.Add(fieldName, entityProperty);
            var result = await TableClient.UpdateEntityAsync<TableEntity>(dynamicEntity, ETag.All, TableUpdateMode.Merge);
            if (result == null || result.IsError) return false;
            return true;
    }

请注意ETAG。所有内容,这将仅扫描不到指定字段。如果您需要检查您要更新的记录的版本,请探索其他选项。此外,请注意,在这种情况下,用于通用值的V,因为它是已经使用t的通用类的一部分。

For anyone hitting this later. Here is an example of property updates in the
Azure.Data.Table world.

        public async Task<bool> UpdateField<V>(string partitionKey, string rowKey, string fieldName, V entityProperty)
        {
            var dynamicEntity = new TableEntity
            {
                PartitionKey = partitionKey,
                RowKey = rowKey
            };
            dynamicEntity.Add(fieldName, entityProperty);
            var result = await TableClient.UpdateEntityAsync<TableEntity>(dynamicEntity, ETag.All, TableUpdateMode.Merge);
            if (result == null || result.IsError) return false;
            return true;
    }

Note the ETag.All, this will simply blanket update the specified field regardless. Explore other options if you need to check the version of the record you are updating etc. Also note, V used for generic value in this instance as it is a part of a generic class that uses T already.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文