UnitOfWork CommitChanges 不编辑数据库行
UnitOfWork CommitChanges not editing DB Row
所以我正在使用 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();
}
我终于让它工作了这是我改变的:
之前:
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();
所以我正在使用 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();
}
我终于让它工作了这是我改变的:
之前:
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();