0
因此,我使用UnitOfWork將對象保存到數據庫中。這完美地工作。但是,當我嘗試編輯對象並再次保存時,不會將更改寫入數據庫。UnitOfWork CommitChanges not editing DB Row
下面是用於保存的片段:
this.uow = new UnitOfWork();
this.job = new Job(uow);
using (UnitOfWork u = new UnitOfWork())
{
job.Truck = cboTrucks.SelectedItem.ToString();
job.Driver = cboDriver.SelectedItem.ToString();
job.Load = txtLoad.Text;
job.Comment = txtComment.Text;
job.FileOk = chkFile.Checked;
job.Notified = chkNotified.Checked;
job.JobDate = dteJobDate.DateTime;
u.CommitChanges();
}
爲什麼要創建Job對象w ith一個UnitOfWork,但然後嘗試將其保存在不同的UnitOfWork下?這似乎很容易導致SessionMixingException。 https://documentation.devexpress.com/#corelibraries/clsDevExpressXpoExceptionsSessionMixingExceptiontopic – Brendon
@Brendon我同意你的看法。我也注意到我所做的是錯誤的。當我解決我的問題時,我很快就擺脫了它。 –