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();
}
我希望在IsRejected
表格中更改SFNewOrder
属性。在SFReject表中插入新记录。但我得到了
内部服务器错误
...上
mdbDataContext.submitchanges();
请帮助...提前致谢。
答案 0 :(得分:0)
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个外键,我需要分配该表的整个对象。 它的工作:))