首页 > 解决方案 > 确定记录是否已更新/插入/删除

问题描述

我有一个名为 APTran 的 DAC。我想确保我在这个 DAC 中的所有记录都已插入。

这是根据相应的 POReceiptLine 未开票数量审核我的 APTran 记录

foreach(APTran apTran in Base.Transactions.Select())
{
   // determine the state of apTran (inserted, Deleted)
}

标签: crudacumatica

解决方案


bool isInserted = cache.GetStatus(apTran) == PXEntryStatus.Inserted;
bool isDeleted = cache.GetStatus(apTran) == PXEntryStatus.Deleted;
bool isInsertedDeleted = cache.GetStatus(apTran) == PXEntryStatus.InsertedDeleted;

InsertedDeleted 是一种特殊情况,记录被插入到缓存中,但在被持久化到数据库之前被删除。

我不知道检查记录是否实际插入数据库的官方方法。我通常做的是检查数据库生成的字段值之一。在插入数据库之前,它们将为空。

bool hasBeenPersisted = apTran.Tstamp != null;

推荐阅读