This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Removing Object from UnitOfWork

Hi All, 

 

I am trying to add some error handling around the UnitOfWork methods.  I have something similar to below

Using uow = session.StartUnitOfWork()

  For each Person in myCollection

    Dim newPerson As IEntity = session.Source.CreateNew("Person")

    bag.PutValue(myField, newValue)

    Try
      bag.ChangeEntity(session, newPerson, True)
      uow.Put(NewPerson)
    Catch ex As Exception
      'logout: ViException.ErrorString(ex)))
    End Try

  Next

uow.Commit()

End Using

 

In some instances bad data causes the uow.Put() method to throw an error and the exception is triggered, however from that point on I am no longer able to use the uow object as it receives this error:

[810300] This unit of work contained errors and can't be used for further operations.

So what I am after is a way to remove the last object added to the UnitOfWork so it can continue processing.

I see there are methods such as uow.flush() and uow.dispose()

Has anyone used these methods?  I am running version 7 and my Object Layer documentation doesn't seem to work since the dell hosted urls were closed down, so I haven't been able to find any documentation on these methods as they are not used in the sample scripts.  Does one of these methods allow the last object to be removed from the UnitOfWork, so I could call it from a finally block?

I could add additional validation to the data coming in to try and prevent the error occurring, however it would be nice to have the error handled and not prevent the remaining bulk updates from occurring.