SubmitChanges() 抛出内部服务器错误
本文关键字:内部 服务器 错误 SubmitChanges | 更新日期: 2023-09-27 17:56:22
public void RejectOrder(string rejectReason, int selectedNewOrderId)
{
SFNewOrder sfNewOrder = mdbDataContext.SFNewOrders.FirstOrDefault(x => x.ID == selectedNewOrderId && !x.IsRejected);
if (sfNewOrder != null)
{
sfNewOrder.IsRejected = true;
}
SFReject sfReject = new SFReject();
sfReject.SFNewOrderID = sfNewOrder.ID;
sfReject.RejectReason = rejectReason;
sfReject.RejectedDate = DateTime.Now;
sfReject.RejectedBy = 2;
mdbDataContext.SFRejects.InsertOnSubmit(sfReject);
mdbDataContext.SubmitChanges();
}
在这里,我想更改SFNewOrder
表中IsRejected
属性并在SFReject表中插入新记录。但我正在得到
内部服务器错误
。上
mdbDataContext.submitchanges();
请帮忙...提前谢谢。
public void RejectOrder(string rejectReason, int selectedNewOrderId, User user)
{
SFNewOrder sfNewOrder = mdbDataContext.SFNewOrders.FirstOrDefault(x => x.ID == selectedNewOrderId && !x.IsRejected);
if (sfNewOrder != null)
{
sfNewOrder.IsRejected = true;
}
SFReject sfReject = new SFReject();
sfReject.SFNewOrder = sfNewOrder;
sfReject.RejectReason = rejectReason;
sfReject.RejectedDate = DateTime.Now;
sfReject.User= user;
mdbDataContext.SFRejects.InsertOnSubmit(sfReject);
mdbDataContext.SubmitChanges();
}
由于我在 SFReject 表中有 2 个外键,我需要分配该表的整个对象。其工作:)