Best way to implement a dirty flag in EF - frameworks

You can easily use the PropertyChanges events to set the flag. But how do you easily reset it after a save to the ObjectContext?

what about the ObjectContext.SavingChanges event? See also http://www.thedatafarm.com/blog/2008/07/13/OverridingObjectContextSaveChanges.aspx.

The above method calls for using the SavingChanges event which is called before the changes are persisted. If there is an error during the save, you have already cleared your dirty flag. I would think there would be a SavedChanges event exposed as well.

Related

How to add an Event object to Unity's EventSystem

If I have an event from Event.current and I want to 'replay' it by making the event system process it again, how do I do that? Can I access the scripts responsible for raising events?
You might be able to track down how events are created using IL Spy then use reflection to invoke that, but unfortunately there is no public API for creating events manually.
I found a neat C# library which simulates input called Windows Input Simulator which does a good job of raising all the keyboard events I needed. Looks like it also works for things like mouse input!

OrientDB callback after record is persisted in server

I'm implementing record versioning using OrientDB, but its callback seems to be invoked right after OOBjectDatabaseTx#save(Object) is called.
Is there any way to get an additional callback for persisted record?
It turned out that we can use ODatabaseListener for this purpose

How can I send event for all mounted tags?

riot.js 2.2
By guides on official site of riot.js I have to call something like
tag.trigger('event_name')
where the tag is the instance of certain listener.
But what must i do to trigger event for all tags?
Has riot.js any implementation for this issue or I have to resolve it manually(by keeping all listeners instances)?
Riot has no implementation of keeping references to all event listeners. So, if you want to execute trigger on them directly, you'll have to implement it yourself.
However, I would recommend to use another solution for notifying multiple event listeners.
If you want to let know multiple tags that an event has occured, you can use a shared observable and handle events on this observable. See this SO question. This way, you don't need to keep refereneces to all event listeners, instead, event listeners need to keep reference to single observable ('event aggregator').
You can also try RiotControl as a shared observable.

CollectionChanged event intercepted by POCO proxy

I have a WPF ListBox with its ItemsSource bound to an ObservableCollection navigation property on an Entity Framework 4 POCO proxy. I want the user to be able to add and remove items to/from the list and then commit those changes by clicking on a [Save] button.
It mostly works, but the ListBox does not show added items until ObjectContext.CommitChanges() is called. It seems that the POCO proxy is intercepting the event for Action.Add operations and then, upon commit, reraising it or maybe a Action.Reset event.
Does anyone know if this is the case. Any possible workarounds to get the desired behavior?
More than likely it's something else; if at the base the property is a collection which implements INotifyCollectionChanged, nothing can stop anybody from subscribing to that event (it's not like routed events or anything). In my experience I never had problems with the proxy properties generated at runtime, at least. Look at how your collection is initialized and double-check your bindings, I'd say.

Asynchronous ObjectContext.SaveChanges()?

I want the SaveChanges of the ObjectContext (Win apps) to save changes asynchronously, will show a marquee (or controllable?) progress bar (this I can easily implement) for the user while he is able to continue working.
I basically want to override the SaveChanges of the ObjectContext.
Has anyone thought about this before?
Entity Framework itself currently does not support asynchronous operations. Mainly because it's built on top of ADO.NET where this isn't supported either. ADO.NET isn't even thread safe by default.
You can use the delegate approach above or wrap it into Task. But that will not use any async calls even if the provider supports it. Also during this "background" operation you should not do anything with the ObjectContext (querying, adding objects, ...) as may result in corrupted state.
Related to multithreading you can read this post. It's older, but ideas are still valid.
Edit 2013-04-17:
EF6 (the next version, currently in alpha stage in time of writing) will support asynchronous operations, namely your requested SaveChangesAsync. It also extended ADO.NET model, so if the provider itself supports asynchronous execution it will be really asynchronous (else back to former behavior as there's nothing better (wise) to do).
Warning: The answer below is old and may not apply to the most recent versions of the framework in question.
I believe you need to use Asynchronous Delegates. It basically works like that:
You create a delegate from the method you want to call asynchronously;
You call BeginInvoke on the delegate, starting a call;
You do whatever else you need to do (e.g. animate a marquee);
You can either wait for the async call to finish, or check whether is has completed and keep animating the marquee if it isn't;