Bindable LINQ: Introduction
Update: SyncLINQ has been released under the name Bindable LINQ, and is available from CodePlex
SyncLINQ is a set of extensions to LINQ that enable data binding over LINQ queries. SyncLINQ alters LINQ queries so that they return INotifyCollectionChanged collections, meaning that when the sources are updated, the result of the LINQ query is also updated.
You can view a 7 minute overview video of what SyncLINQ is, see it in action, and some of the features here:
As you’re probably aware, there are a large number of LINQ extension methods, and I’m slowly implementing more of them. An early Alpha which I hope to release late this week currently supports:
Where()Select(), including projections into anonymous typesOrderBy(),ThenBy()both ascending and descendingUnion()
As well as two custom extension methods:
Asynchronous()Polled()
For more information, please check out the video
Technorati tags: LINQ, SyncLINQ, Paul Stovell
Filed under: Bindable LINQ


Very impressive indeed! Am I blind, though, or do you not have a link to this library? I’d love to start making use of it in a project I’m working on.
Hi William,
I don’t have a linq (hehe) to download it /yet/ - there’s a bit of a code review process I want to go through before I make it available. I’ll hope to have it all sorted during the week.
Paul
SyncLINQ
Cool library coming soon: http://www.paulstovell.net/blog/index.php/introducing-synclinq/ . This allows
Pingback from http://oakleafblog.blogspot.com/2007/10/linq-and-entity-framework-posts-for_15.html (”Paul Stovell Introduces SyncLINQ for Databinding LINQ Queries”)
Paul Stovell has been working on an interesting extension to LINQ called SyncLINQ.
The basic premise is that when you data bind to a LINQ expression today…
Paul,
I started work on a similar thing that I called Streaming LINQ over at CodePlex — www.codeplex.com/slinq.
I’ve been very busy lately, so I haven’t had much time to work on it since beta 2, but perhaps we can combine our efforts?
LINQ + Binding-Oriented Programming… so THAT’S what you’ve been up to Paul!
Elegant solution Paul!
I love the idea of using the INotifyCollectionChanged with the Asynchronous call.
I’ve written something similar, but focused more on supporting the CRUD with Linq to SQL - so I’m using a IBindingList implementation behind the scenes.
http://mathgeekcoder.blogspot.com/2007/09/updatable-inheritable-wpf-bounded-linq.html
Any chance SyncLinq could support IBindingList? Otherwise I’ll just have to steal your good ideas
Observable LINQ
So I have been neglecting my blog, Observable LINQ Part 3 never made it and it now looks like Paul Stovell will beat me to release with his SyncLINQ project. Head over to his blog for a nice screencast on the technology. This is…
@Oren - There do indeed look to be similarities - I’ll email you privately to discuss
@Luke - In the video I mention support for Windows Forms, and the way I planned to do this was by supporting INotifyCollectionChanged as well as IBindingList. The IBindingList would however be read-only, but sorting etc. should all work.
Hey Paul,
This will only help in the binding where the collection changes, but won’t help with notifying when the properties of any item changes, right ?
BTW: where’s the code ?
Introducing SyncLINQ (Databinding with LINQ)
You’ve been kicked (a good thing) - Trackback from DotNetKicks.com
Hi Bill,
I have plans around a “Dependency” extension or parameter that can be passed into the extensions - for example:
contacts.Where(c => c.Name == “Paul”, “Name”)
This will subscribe to PropertyChanged events on the contact and if the Name changes, will re-apply the filter. It’s not 100% baked though.
Paul
On the dependency parameter above, note that when an Object’s property changes, even if a query is applied, the objects bound to the form are the same as the ones in the source collection - so PropertyChanged events would work.
The only times where SyncLINQ would need to treat PropertyChanged events is in queries that rely on a property - grouping, distincts, where, order by, as well as select.
Select is particularly tricky - you won’t be able to project into an anonymous type and get PropertyChanged events, since anonymous types in LINQ don’t implement INotifyPropertyChanged. You could however project into known-types which you’d define yourself.
Paul
SyncLINQ
This is very cool stuff from down under.
SyncLINQ is a set of extensions to LINQ that enable data binding…
Are you using expression trees or delegates/lambdas ? If expression trees, the “Name” part is superfulous as you can determinen that from the tree.
But for the most part, there’s really only two routes that can be followed here: (1) is use types that implement INotifyPropertyChanged as the return elments of queries, which typically means that the Select returns the same type T as the originaly IEnumerable(Of T)
or te retrun elemnt type is elsewhere defined already, OR (2) use late bound structures akin to data row.
I’m using extension methods and lambdas - no expression trees/custom query providers.
Yes, if the type implements INotifyPropertyChanged, then the results of the query will have the same instances of those elements (assuming you don’t project them into another type), and so property changed events will work.
If you project, you have to project into either a known type which you define, a late bound one like you suggested (I’m thinking of defining a “SyncLinqProjection” object which implements ICustomTypeDescriptor) or an anonymous type - but the anonymous type won’t raise events.
Paul
[…] Link to PaulStovell.NET » Introducing SyncLINQ […]
[…] Since we were coding LINQ, we obviously had to take a look at SyncLINQ. […]
SyncLink - LINQ extensions for data binding
Readify colleague Paul Stovell has been working on an extension to LINQ for a while. He's finally
[…] « F# and Silverlight Demos GridLINQ October 21st, 2007 With a number of LINQ extensions already in development (PLINQ from Microsoft being one of them), my suggestion is for […]
Desparately need this! Any updates when this will be available?
[…] promised, I have made the SyncLINQ source code available from Subversion via this […]
SyncLINQ [Rob Farley]
Paul Stovell is just too smart. About six weeks ago I heard a presentation of his at the Adelaide .Net
[…] I believe that managing state is the direct cause of most complexity in desktop applications, and SyncLINQ is designed to address that. Let me explain why I believe this, and why SyncLINQ might help, in the […]
Nifty!
The polling idea, though, strikes me as a scary approach. Always rerunning the query every few seconds could be a big problem, depending on the data source.
Instead, in the case of SQL Server 2005 or greater, a strategy to use Query Notifications (http://msdn2.microsoft.com/En-US/library/ms130764.aspx) might be better. Make it the default (force people to opt into a potential problem).
You could also pass a function that returns true if you need to refresh. This would allow polling of a timestamp or other version indicator.
Paul, I was just wondering if SyncLINQ will work with ADO.NET’s Entity Framework , or more specifically, Linq to Entities?
TIA
Is SyncLINQ going to work with the ADO.NET Dataservice client context?
[…] Now that’s a technology I would be happy to use any day. I’ve also looked at SyncLinq from Paul Stovell and that fits nicely with my domain modelling world. Before you say it, […]
[…] wonder now, though, whether SyncLINQ might have taken care of this for me. Had I done a "union" LINQ query from folders, […]
[…] that makes SyncLINQ tricky is the number of possible things that can happen to a source collection to affect the […]
[…] updates for when the datasource updates, I strongly recommend looking into the very clever SyncLINQ by the equally clever Paul Stovell, which also supports […]
[…] by Mahesh Kirshnan (’How well do you know your IDE?’) and Paul Stovell (’SyncLINQ‘). Phillip Beadle’s presentation on Test Driven Development reminded me of my urgent […]
[…] Maintaining complex state - SyncLINQ to the rescue! Paul Stovell has created a LINQ library that can be used to simplify the maintenance of state in complex (and even not so complex) […]
Nice! Hey if one is interested there is more information on linq at linqhelp.com Good luck!