This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I've got a Parallel.ForEach loop that calls methods in my repository. Those methods use a singleton UnitOfWorkHolder that is built around PerThreadUnitOfWorkScope. I recently ran into an issue where I got an optimistic concurrency exception in a method when I was trying to insert some new rows. The exception mentioned a table that was not in the method being called. I'm wondering if this is because of the scoping of my unit of work. In my methods, I am calling SaveChanges(true), which I thought would have taken care of any issues but that is not the case. Each repository method should be short and sweet and shouldn't be longer running. Inside my UnitOfWorkHolder class, I have a singleton private static UnitOfWorkHolder _holder; My CreateUnitOfWorkHolder method creates the instance:
return holder ??
(holder =
new UnitOfWorkHolder(
new PerThreadUnitOfWorkScope My repository methods when use the unit of work: dbUnitOfWork uow = UnitOfWorkHolder.UnitOfWork; |
|
|
Yes definitely sounds a bit odd. That type of exception is only triggered with an update on a versioned entity, are you performing an update that would match up to that at an earlier stage in the programs execution? Also how are you covering off disposal of the UnitOfWork after the methods execute?
|
|
|
So, I put in a hack I found in the forums to reset the unit of work without saving and that helped. Now, I'm getting this exceptions periodically, though: at System.Data.OracleClient.OracleCommand.GetStatementHandle()
at System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean needRowid, OciRowidDescriptor& rowidDescriptor)
at System.Data.OracleClient.OracleCommand.ExecuteNonQuery()
at ...?()
at Mindscape.LightSpeed.Profiling.Interceptor.ExecuteCommand(Func Invalid operation. The connection is closed. I create my unit of work holder like this:
Dispose looks like this, but has no references to it in code.
The app continually runs and in theory never disposes anything. Maybe that's the issue. It's a batch app that is suppose to run 24/7. |
|