gpt4 book ai didi

Azure 表存储 : Ignoring a property of a TableEntity when using the Azure. Data.Tables 包

转载 作者:行者123 更新时间:2023-12-02 05:50:46 30 4
gpt4 key购买 nike

我正在使用 Microsoft 的新 Azure.Data.Tables 库来处理 Azure 表存储。在旧库中,当您有一个实现 ITableEntity 的实体并且您有一个不想保存到存储表的属性时,您将使用 [IgnoreProperty] 注释。但是,这在新库上似乎不可用。

Azure.Data.Tables 包上的等效项是什么,或者现在如何避免将属性保存到表存储?

这是我想要坚持的类(class):

public class MySpatialEntity : ITableEntity
{
public int ObjectId { get; set; }
public string Name { get; set; }
public int MonitoringArea { get; set; }

//This is the property I want to ignore because table storage cannot store it
public Point Geometry { get; set; }

//ITableEntity Members
public virtual string PartitionKey { get => MonitoringArea.ToString(); set => MonitoringArea = int.Parse(value); }
public virtual string RowKey { get => ObjectId.ToString(); set => ObjectId = int.Parse(value); }
public DateTimeOffset? Timestamp { get; set; }
public ETag ETag { get; set; }
}

最佳答案

从版本 12.2.0.beta.1 开始,Azure.Data.Tables 表实体模型现在支持通过 [IgnoreDataMember] 在序列化期间忽略属性。属性并通过 [DataMember(Name="<yourNameHere>")] 重命名属性属性。

查看变更日志 here .

关于Azure 表存储 : Ignoring a property of a TableEntity when using the Azure. Data.Tables 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68633776/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com