c# - 有关如何教程(WPF/Entity Framework/ObservableCollections)的问题

标签 c# wpf linq entity-framework

我观看了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/

相关文章:

wpf - 使用 WPF WebBrowser 将字典传递给 ObjectForScripting

c# - 寻找 mainviewmodel 上 MVVM 文本 block 绑定(bind)的指导

时间:2019-03-08 标签:c#linqwhereconditionalif

c# - BitmapFactory.DecodeStream 上的 Android 单声道退出代码 255

c# - Xamarin.Forms 目标框架 (Kitkat) 问题

c# - 如何忽略单元格编号格式中的格式错误标志

wpf - 更改绑定(bind)属性的值时如何为文本 block 的背景设置动画?

c# - 在List<T>中选择整周没有休息日的记录 - C#

c# - LINQ 表达式未被转换为 SQL

c# - 停在正则表达式中的单词