我工作的地方有这个函数,它将对象信息插入到数据库中,它返回在插入时创建的ID但是......,它们将此函数作为bool返回,无论它是否能够提交或不是交易。我希望能够使用它返回的ID,但我不知道如何访问它,它将它分配给实体,但函数返回一个布尔..所以它有点令人困惑..
//HERE IT IS SAVING THE ID INTO THE ENTITY BUT I AM NOT SURE HOW TO ACCESS IT ?.
myentity.ObservationID = (System.Int32)_observationID;
myentity.AcceptChanges();
OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));
return Convert.ToBoolean(res);
在提交按钮中,它正在做这样的事情
bool observationInserted = false;
observationInserted = observationAdmin.Insert(observationEntity);
if(observationInserted)
{
I need to grab the observation id that was saved, the code in the inserting function seems
to be doing this but it returns boolean, I need the ID and the boolean.
then it will navigate somewhere appending the id.
}
NoteL在提交按钮中调用插入后,它转到某种事务验证管理器,然后从那里调用插入函数和事务结果。
答案 0 :(得分:1)
您的观察实体将使用唯一ID进行更新。
您可以通过引用ID属性来获取它:observationEntity.ObservationID