Linq 有人能告诉我这个BPM有什么错误吗

Linq 有人能告诉我这个BPM有什么错误吗,linq,business-process-management,epicorerp,Linq,Business Process Management,Epicorerp,此代码将自动生成新零件号。这是BO GetNewPart的后处理BPM int iPartnum = 0; string cPartid = string.Empty; Erp.Tables.Company Company; foreach (var ttpart_xRow in ttPart) { var ttpartRow = ttpart_xRow; Company = (from Company_Row in Db.Company where

此代码将自动生成新零件号。这是BO GetNewPart的后处理BPM

int iPartnum = 0;
string cPartid = string.Empty;
Erp.Tables.Company Company;
foreach (var ttpart_xRow in ttPart)
{
    var ttpartRow = ttpart_xRow;
    Company = (from Company_Row in Db.Company
               where Company_Row.Company == Session.CompanyID
    select Company_Row).FirstOrDefault();
    iPartnum = (decimal)Company["AutoGenerate_c"] + 1;
    cPartid = System.Convert.ToString(iPartnum);
    ttpartRow.PartNum = cPartid;
    Services.Lib.UpdateTableBuffer._UpdateTableBuffer(Company,"AutoGenerate_c", iPartnum);
}

它只是不工作还是有错误消息

Services.Lib.UpdateTableBuffer._UpdateTableBuffer(Company,"AutoGenerate_c", iPartnum);
我个人从来没有使用过,甚至没有见过这个Lib项目,所以我不能担保它。我会在事务范围内手动更新对象,因为我怀疑GetNewPart是否接触过该数据库,因此可能不会创建事务

using (System.Transactions.TransactionScope txScope = IceDataContext.CreateDefaultTransactionScope())//start the transaction
{
   //Your Logics go here
   Db.Validate();
   txScope.Complete();//commit the transaction
}

顺便说一句,我尽量不让这类事情出现在公司记录中,因为系统中几乎每一个进程都会接触到它,我不希望某个进程将其锁定或造成奇怪的竞争条件。我通常喜欢保留一个记录,它只会为了这个特定的目的而被触动,所以我有一个UDCodeType/UDCode用于这类事情

它只是不工作还是有错误消息

Services.Lib.UpdateTableBuffer._UpdateTableBuffer(Company,"AutoGenerate_c", iPartnum);
我个人从来没有使用过,甚至没有见过这个Lib项目,所以我不能担保它。我会在事务范围内手动更新对象,因为我怀疑GetNewPart是否接触过该数据库,因此可能不会创建事务

using (System.Transactions.TransactionScope txScope = IceDataContext.CreateDefaultTransactionScope())//start the transaction
{
   //Your Logics go here
   Db.Validate();
   txScope.Complete();//commit the transaction
}
顺便说一句,我尽量不让这类事情出现在公司记录中,因为系统中几乎每一个进程都会接触到它,我不希望某个进程将其锁定或造成奇怪的竞争条件。我通常喜欢保留一个记录,它只会为了这个特定的目的而被触动,所以我有一个UDCodeType/UDCode用于这类事情