crud - 确定记录是否已更新/插入/删除
问题描述
我有一个名为 APTran 的 DAC。我想确保我在这个 DAC 中的所有记录都已插入。
这是根据相应的 POReceiptLine 未开票数量审核我的 APTran 记录
foreach(APTran apTran in Base.Transactions.Select())
{
// determine the state of apTran (inserted, Deleted)
}
解决方案
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;
推荐阅读
- javascript - 如何使用firebase云功能从firebase数据库中检索子节点的键值?
- c++ - 如何在公共类 C++ 中访问变量的值
- python - Pandas 根据多列中的值映射
- r - 如何计算多个表中的变量以生成新列?
- php - 如何正确配置 php - CENTOS 6
- java - Java 扫描器第二个输入以缩小搜索范围
- java - 如何使用 tempArray 将字符串分成两个双精度数?
- wordpress - admin-ajax.php 中的 Ajax 发布调用返回 0 和 400 错误请求(Wordpress)
- python - 如何在循环期间分配新变量?
- corda - Corda V4 合同和流测试用例在 Windows 上的 IntelliJ 中运行