Search code examples
devexpressdevexpress-windows-ui

UnitOfWork CommitChanges not editing DB Row


So I'm using UnitOfWork to save object to a Database.. This work perfectly. However, when I try to edit the object and save it again, no changes are written to the Database.

Here is the snippet used for saving:

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

Solution

  • I finally got it working this is what I changed:

    BEFORE:

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

    AFTER:

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