Tag: entitycollection

EntityFramework EntityCollection观察CollectionChanged

我首先在应用程序中使用EntityFramework数据库。 我想以某种方式通知我的ViewModel中的EntityCollection更改。 它不直接支持INotifyCollectionChanged (为什么?)并且我没有成功找到另一个解决方案。 这是我的最新尝试,由于ListChanged事件似乎没有被提升,因此无效: public class EntityCollectionObserver : ObservableCollection, INotifyCollectionChanged where T : class { public event NotifyCollectionChangedEventHandler CollectionChanged; public EntityCollectionObserver(EntityCollection entityCollection) : base(entityCollection) { IBindingList l = ((IBindingList)((IListSource)entityCollection).GetList()); l.ListChanged += new ListChangedEventHandler(OnInnerListChanged); } private void OnInnerListChanged(object sender, ListChangedEventArgs e) { if (CollectionChanged != null) CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } } 有没有人有任何想法我如何观察EntityCollection变化? 担

如何对绑定到EF EntityCollection 的WinForms DataGridView进行排序

我正在尝试将WinForms DataGridView绑定到EntityFramework4对象的EntityCollection 。 麻烦的是,我无法弄清楚如何让它(自动)排序。 我所做的就是将BindingSource的DataSource属性设置为实体的集合。 MyBindingSource.DataSource = CurrentItem.InvoiceNotes; 我真的希望我可以添加一个简单的配置来使它工作; 我真的不想将我的EF Collection包装在一个新的BindingList容器中。