Azure table 助手检查正在保存的项目是新的还是旧的

Azure table helper check if the item being saved is new or old

在我的 Azure 应用程序中,我有一个像这样的模型的保存功能

public Organization Save()
{
    TableHelper.Save<Organization>(this);
    // I want to check is this a new entry or an old one being saved?
    return this;
}

所以我想检查一下这是旧条目还是正在制作的新条目。我可以拥有自己的属性,但我希望 azure 会为这个东西内置一些东西。

根据我的经验,如果当前没有逻辑来实现它,也许我们无法找到一种方法来知道已经完成了什么操作(插入或更新)。但是正如您提到的,我们可以通过添加 属性 来轻松实现它。 如果愿意,您也可以将 feedback 发送给 Azure 存储团队。

您可以使用 Azure Table 存储提供的时间戳 属性。添加一个数据类型为 Edm.DateTime 的列。您可以将您的逻辑仅用于根据需要更新该列,并且 Azure Table 的时间戳将自动更新。