I'm evaluating OpenAccess as ORM backend for my application.
I'm developing WPF application with large amount of long running thread.
As i read in this thread
, I understand that it is preferred for each thread to have it's own context.
I have enabled the L2 cache as well.
I have successfully perform update from thread A and read the change from thread B using the context Refresh() method. Unfortunately, the refresh method doesn't raise the PropertyChanged event, so my View doesn't reflect the latest data.
Here is my simplified example code:
// Get the context of the main thread
var mainContext = ContextManager.GetContext(Thread.CurrentThread.ManagedThreadId);
Person personMain = mainContext.Persons.Single(p => p.Id == 1);
// Get the context of the new thread.
var threadContext = ContextManager.GetContext(Thread.CurrentThread.ManagedThreadId);
Person personThread = threadContext.Persons.Single(p => p.Id == 1);
// At this point, personMain.Name value is "Old Name".
// Now refresh the person instance of the main thread.
// At this point, personMain.Name value is correctly changed to "New Name",
// but personMain.PropertyChanged event is not fired.
I can avoid the PropertyChanged issue by sharing the main thread's context to other threads, but I'm afraid it will introduce other concurency problem. My application will have hundreds of long running threads during its lifecycle. Sharing a context for hundreds thread means share a transaction over hundres threads, and I think this is not good solution.
Did I miss something, or is there any better solution for my case?