开发者

Persisting of ObservableCollection<T> to DataStore

I have an ObservableCollection<T> (T being a set of entities loaded using OData)开发者_JAVA百科 which is correctly maintaining updates to its contents. The collection is displayed in a DataGrid and the user clicks a button in order to save the collection back to a database.

Is there any way that I can test the collection for updated items, limiting the number of writes required to those entities that have actually been updated.


If you use the .NET Entity Framework for interacting with the database, it will do a lot of this for you.

But if you want to do it from scratch the easiest way is to implement INotifyPropertyChanged on each item in the collection. When soemthing is added to the collection, add a listener to it's PropertyChanged event. Now you can get notified of and keep track of all changes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜