Is binding on nested collections supported?

May 7, 2009 at 4:40 PM
Edited May 8, 2009 at 9:58 AM

In this scenario I have a collection of items, and each item has a collection of sub-items.  I want BindableLINQ to return me a list of all the sub-items in all items. 

I've included the code which tests this scenario, but where the standard LINQ query correctly retuns 1 sub-item the BindableLINQ version doesn't update and returns zero sub-items.

Is this not supported, or have I made an error in my usage?

    class Program
        static void Main(string[] args)
            Root r = new Root();

            var bindableLinqResult = r.Items.AsBindable().SelectMany(i => i.SubItems.AsBindable());

            Item a = new Item();
            a.SubItems.Add(new SubItem());

            var standardLinqResult = r.Items.SelectMany(i => i.SubItems);

            Console.WriteLine("BindableLINQ: " + bindableLinqResult.Count);
            Console.WriteLine("LINQ: " + standardLinqResult.Count());

    class Root
        ObservableCollection<Item> items = new ObservableCollection<Item>();
        public ObservableCollection<Item> Items { get { return this.items; } }

    class Item
        ObservableCollection<SubItem> subItems = new ObservableCollection<SubItem>();
        public ObservableCollection<SubItem> SubItems { get { return this.subItems; } }

    class SubItem { }

May 8, 2009 at 9:56 AM

Update: I just tried the above scenario with ComponentOne's LiveLINQ and it works correctly, so this does appear to be a limitation of the current version of BindableLINQ.


May 8, 2009 at 3:25 PM

Yes, it looks like SelectMany is not working properly, I tried to do similar things and failed too.

Jul 31, 2009 at 9:47 AM

This was the first thing I tried :/

Is there any straightforward workaround?

Sep 4, 2009 at 10:08 PM

I am also having a very similar problem. I haven't been able to think of any suitable work around because it appears the union just isn't working either.  I know there is another post about this problem.  I looked at the posted solution and haven't been able to get it working.  Does anybody know if this project is still being actively maintained?