views:

44

answers:

1

i watched How Do I: Build a WPF Data Entry Form Using Entity Framework?

very confused around 15:30. when the presenter said something like

when you create a LINQ query, we wont get a rich collection ...

whats does she mean my "rich".

the start code looks like... whats wrong with that. even if i change db.Customers.Execute(...) with a LINQ query, the code still works. why the need for a new observable collection and why ListCollectionView instead of BindingListCollection view. whats the diff between the 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;

the code after looks like (~21:38)

results = from cust in db.Customers ...
customerData = new CustomerCollection(results, db);
customerSource.Source = customerData
view = (ListCollectionView) customerSource.View;
+2  A: 

She means that you'll get back an IEnumerable, which doesn't have any support for two way binding or extra facilities like notifications of add/remove events, that are available in other collection types. So, the code is taking the IEnumerable and putting the results into a "richer" collection type that has those kinds of features.

Richard Hein
but i find that if i replace `customerSource.Source = db.Customers.Execute(...)` with `customerSource.Source = from cust in db.Customers select cust` it still works fine. why did she use ListCollectionView instead of BindingListCollectionView? am i missing something? sorry not that i insist of BindingListCollectionView or something, i just dont understand the reason for the switch
jiewmeng
Have you tried adding or removing rows and saving? If you bind directly to the LINQ query, you're updates from the UI don't get saved.
Richard Hein