C# 关于如何学习教程(WPF/实体框架/可观察集合)的问题
我看着 15点半左右我很困惑。当主持人说 当您创建LINQ查询时,我们不会得到丰富的集合 她说我的“有钱”是什么意思 开始代码看起来像。。。那有什么不对。即使我使用LINQ查询更改db.Customers.Execute(…),代码仍然有效。为什么需要新的可观察集合,为什么ListCollectionView而不是BindingListCollection视图。这两者之间有什么区别C# 关于如何学习教程(WPF/实体框架/可观察集合)的问题,c#,wpf,linq,entity-framework,C#,Wpf,Linq,Entity Framework,我看着 15点半左右我很困惑。当主持人说 当您创建LINQ查询时,我们不会得到丰富的集合 她说我的“有钱”是什么意思 开始代码看起来像。。。那有什么不对。即使我使用LINQ查询更改db.Customers.Execute(…),代码仍然有效。为什么需要新的可观察集合,为什么ListCollectionView而不是BindingListCollection视图。这两者之间有什么区别 // customerSource is a CollectionViewSource stored in Win
// 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)
她的意思是,您将得到一个IEnumerable,它不支持双向绑定或额外的功能,如添加/删除事件通知,这些功能在其他集合类型中可用。因此,代码采用IEnumerable并将结果放入具有这些特性的“更丰富”集合类型中。但我发现如果我将
customerSource.Source=db.Customers.Execute(…)
替换为customerSource.Source=from cust in db。客户选择cust
仍然可以正常工作。为什么她使用ListCollectionView而不是BindingListCollectionView?我错过什么了吗?很抱歉,我不是坚持使用BindingListCollectionView之类的,我只是不明白切换的原因。您是否尝试过添加或删除行并保存?如果直接绑定到LINQ查询,则无法保存来自UI的更新。
results = from cust in db.Customers ...
customerData = new CustomerCollection(results, db);
customerSource.Source = customerData
view = (ListCollectionView) customerSource.View;