LinqBindingList and join query

LinqBindingList and join query

Old forum URL:

tchimev posted on Thursday, June 11, 2009

I use CSLA 3.6.3
I would like to use LinqBindingList so I can bind the result from a linq query to a win form control through Visual Studio designer.

I have two collections:


The collections contain different employees.
I want my linq query to return only employees that are contained in both collections.

So my query look like this:

            LinqBindingList<BO.User> result = (from e1 in BLBEmployees1
                                                                   join e2 in BLBEmployees2 on e1.ID equals e2.ID
                                                                   orderby e1.Name
                                                                   select e1) as LinqBindingList<BO.User>;

But after I run the query the 'result' is null!

If I rewrite that query to return IQuerable<BO.User> I get a valid result but I cannot bind it to a control through the Visual Studio designer.

Could someone help me with that query?

tchimev replied on Thursday, June 11, 2009

Any help is welcome.

RockfordLhotka replied on Friday, June 12, 2009

You can't get a LinqBindingList from a join, it simply can't work. LinqBindingList is a view over an underlying collection - a join involves two collections and we can't create a live view over two collections.

tchimev replied on Friday, June 12, 2009

Thank you Rocky!

tchimev replied on Monday, June 15, 2009

I am looking to find a good way to use advanced filter operation, but I cannot come up with any.

I would like to filter a BLB or ROL collection over another collection, using linq query, store the result to a property and then bind that property to a win form control.
It will be nice if that property can be bound through the Visual Studio designer.

I found some projects on CodePlex about linq binding, like 'BindableLinq', 'ContinuousLinq', 'Obtics', but
some of them return interface as a result from a query, and I cannot bind property of type interface  through the studio designer.
'ContinuousLinq' wants me to wrap my collection with it's own collection and then use linq query over it.
I'm looking for something simpler like LingBindingList but with advanced filtering.

Is that possible and how should I achieve it?
Has anyone faced such a requirement?

JoeFallon1 replied on Monday, June 15, 2009

Here is one idea which may or may not work for you:

Dig in to the CSLA LinqBindingList Code and see if you can modify it to meet your requirements. As Rocky stated the LBL maintains a view over your original list.

But while it is constructing the cross reference index it creates a "subset" which is a new list. It grabs the indexes from this subset and aligns them with your original list to build the cross reference.

Then it "throws away" the subset.

It may be useful to you if you can find a way to keep the subset around and use it.


tchimev replied on Monday, June 15, 2009

Thank you Joe,

I will look at linqBindingList code,
any other ideas are welcome.

ThomasP replied on Thursday, June 18, 2009


I think it should be easy to create a wrapper class for the IEnumerable<> and INotifyCollectionChanged interfaces. The class could accept such an interface as parameter for its constructor. It could simply pass through the methods and events from these interfaces. The class would give you a concrete type to bind to.

All you need to do then is return an instance of your wrapper class from your property instead of the original interface.



Copyright (c) Marimer LLC