我观看了How Do I: Build a WPF Data Entry Form Using Entity Framework?
15:30 左右非常困惑。当主持人说类似
时when you create a LINQ query, we wont get a rich collection ...
她说我的“富有”是什么意思?
起始代码看起来像......这有什么问题。即使我使用 LINQ 查询更改 db.Customers.Execute(...) ,代码仍然有效。为什么需要新的可观察集合以及为什么 ListCollectionView 而不是 BindingListCollection View 。 2 之间有什么区别
// customerSource is a CollectionViewSource stored in Window.Resources
// db is of type OMSEntities (which is the Entity Collection Name, what does this mean?)
customerSource.Source = db.Customers.Execute(...);
this.view = (BindingListCollectionView) customerSource.View;
之后的代码看起来像 (~21:38)
results = from cust in db.Customers ...
customerData = new CustomerCollection(results, db);
customerSource.Source = customerData
view = (ListCollectionView) customerSource.View;
最佳答案
她意味着您将返回一个 IEnumerable,它不支持双向绑定(bind)或其他集合类型中可用的额外功能(例如添加/删除事件的通知)。因此,代码采用 IEnumerable 并将结果放入具有这些功能的“更丰富”的集合类型中。
关于c# - 有关如何教程(WPF/Entity Framework/ObservableCollections)的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3640949/