How can I do that?
thats a no go:
ObservableCollection obsCol = new ObservableCollection(myIEnumerable);
scenario:
var query = from c in customers
select new Customer()
{
Products = from p in products
where p.Id = c.Id
select p
};
Products is a ObservableCollection so it can not take the IEnumerable result from the select above…
How to cast?
Like this:
Note that the
ObservableCollectioninstance will not reflect changes to thecustomerslist.EDIT: The Select extension method returns an instance of a compiler-generated iterator class. Since this class does not inherit
ObservableCollection, it is impossible to cast it to one.