跟踪变化的集合?
是否有任何集合可以跟踪对集合所做的更改?说出哪个对象被删除/修改/添加?
ObservableCollection 只是提供通知,它不会将删除的内容保留在“RemovedItems”属性中。我必须把它们放在某个地方。实际上我问这个问题的原因是,如果我将一个集合绑定到数据网格,似乎我必须自己进行更改跟踪,我希望有一个集合可以执行此操作,以便我知道如何使用该集合更新数据库。
DataTable 跟踪更改,但使用起来并不容易。
is there any collection that track changes made to the collection? say which object is deleted/modified/added?
The ObservableCollection just give notifications, it will not keep the removed in say a RemovedItems property. I have to keep them somewhere. actually why i am asking the question is if i bind a collection to a datagrid, it seems i have to do the change tracking myself, i wish there is a collection will do this so that i know how to update database using the collection.
The DataTable tracks changes, but it is not so easy to work with.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试ObservableCollection。从参考文本来看:
编辑。您可能还想尝试使用数据集来解决您的问题(即 DataSet 类及相关)。他们可以进行行版本控制并跟踪行状态更改(新建、编辑、删除),因此它可能适合您。这是对该主题的很好的介绍: http://msdn.microsoft.com/ en-us/library/ww3k31w0.aspx
Try ObservableCollection. From the reference text:
EDIT. You may also want to try solving your problem by using data sets (i.e. the DataSet class and related). They can do row versioning and keep track of row state changes (new, edited, deleted), so it may work for you. This is a good introduction to the topic: http://msdn.microsoft.com/en-us/library/ww3k31w0.aspx