UnitOfWork CommitChanges不编辑DB Row

时间:2015-07-13 13:36:36

标签: devexpress devexpress-windows-ui

所以我使用UnitOfWork将对象保存到数据库..这完美。但是,当我尝试编辑对象并再次保存时,不会对数据库进行任何更改。

以下是用于保存的代码段:

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();
            }

1 个答案:

答案 0 :(得分:0)

我终于得到了它,这就是我改变了:

在:

this.uow = new UnitOfWork();
this.job = new Job(uow);

在:

this.uow = new UnitOfWork();
this.job = new XPQuery<TIS.Model.Internal.Job>(uow).Where(q => q.Id == job.Id).FirstOrDefault();