Share via


How to select() or selectmany() from ObservableCollection

Question

Monday, May 10, 2010 4:08 PM

I have a collection of ObservableCollection<Member>. and i want to select multiple members who are active. The member obejct has "IsAvtive" property

All replies (4)

Monday, May 10, 2010 4:51 PM ✅Answered

An ObservableCollection<T> is just an IEnumerable<T>, so you can use the usual extension methods, provided you added the required namespace. If you did, you can do myObservable.Select(item => item.IsActive)Dennis Doomen
Principal Consultant at Aviva Solutions
Blog, Twitter, Fluent Assertions


Tuesday, May 11, 2010 2:48 PM ✅Answered

The Select returns an IEnumerable. So it get it back to an ObservableCollection, you have to cast it back.

Hope this helps.

www.insteptech.com ; msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!


Monday, May 10, 2010 5:00 PM | 2 votes

           

var query = from p in ObservableCollection<Member>
             where p. IsAvtive = "active"
             select p;

I love what i am doing


Tuesday, May 11, 2010 2:30 PM

but im not able to do

ObservableCollection<Member> result = myObservable.Select(item => item.IsActive)