tags:

views:

72

answers:

2

i am watching this tutorial. at around 15:40, the speaker said something like a LINQ query won't create a rich collection like BindingListCollectionView. i am thinking maybe it means changes wont be saved to the database or something. so i tried replacing

var result = database.Customers.Execute(System.Data.Objects.MergeOption.AppendOnly);

with

var result = from cust in database.Customers
             where cust.City == "Seattle"
             select cust;

and all still works fine.

+9  A: 

ObservableCollection have an event that is fired when their contents changed so a ListView, ComboBox, etc can stay in sync with your data when it changes. If the contents of the list will never change then having an ObservableCollection is not necessary.

Jake Pearson
can i say that "feature" does not exist in `BindingListCollectionView`?
jiewmeng
If you want to use BindingListCollectionView instead you could take your result (which is an IEnumerable) and shove it into a new BindingListCollectionView or ObservableCollection
Jake Pearson
A: 

Sometimes you can't use an ObservableCollection as you have custom collection classes already written that you want to bind to. In this situation you can implement the ICollectionChanged and IPropertyChanged interfaces on your custom collection.

Your custom collection will then work like an ObservableCollection (or at least to the extent of implementation in your collection).

Ristogod