Overview

Bindable LINQ is a set of extensions to LINQ that add data binding and change propagation capabilities to standard LINQ queries.

Bindable LINQ 1.0 Beta 1

Download here.

How does it help?

Suppose you wrote the following LINQ to Objects query:

ObservableCollection<Contact> contacts = new ObservableCollection<Contact>();
itemsControl.ItemsSource = from c in contacts
                           where c.Name.StartsWith("P")
                           select c;
contacts.Add(new Contact() { Name = "Omar" });
contacts.Add(new Contact() { Name = "Paul" });

Developers familiar with Windows Presentation Foundation or Silverlight know that the ObservableCollection<T> class is designed to propagate change; that is, it raises CollectionChanged events when items are added to the list. However, if you wrote the code above, you would find that neither Omar nor Paul appear on the screen. Why?

It turns out that the objects returned by a LINQ to Objects query do not provide CollectionChanged events. The out of the box LINQ experience makes it difficult for rich client developers to display changes to data while simultaneously using LINQ.

That's where Bindable LINQ comes in. With a minor code change, we can enable change propagation over LINQ to Objects queries:

ObservableCollection<Contact> contacts = new ObservableCollection<Contact>();
itemsControl.ItemsSource = from c in contacts.*AsBindable()*
                           where c.Name.StartsWith("P")
                           select c;
contacts.Add(new Contact() { Name = "Omar" });
contacts.Add(new Contact() { Name = "Paul" });

What else does it do?

As well as propogating change, Bindable LINQ can analyse your queries at runtime and detect any dependencies your query has. If these dependencies provide events to subscribe to, Bindable LINQ will automatically monitor them for change.

Take this query for example:

contactsListBox.ItemsSource = from c in customers
                              where c.Name.StartsWith(textBox1.Text)
                              select c;

Bindable LINQ will detect that the query relies on the Text property of the TextBox object, textBox1. Since the TextBox is a WPF control, Bindable LINQ knows to subscribe to the TextChanged event on the control.

The end result is that as the user types, the items in the query are re-evaluated and the changes appear on screen. No additional code is needed to handle events.

How much of the LINQ syntax is supported?

The aim of Bindable LINQ is to be fully compatible with LINQ to Objects, at least where it makes sense. This already includes support for operations such as Where, Select, GroupBy and Union. Aggregates, such as Sum, Min, Max and Average, are also supported. For more information, see the LINQ Compatibility page.

What platforms does it support?

Bindable LINQ is designed for Windows Presentation Foundation, Silverlight, and Windows Forms. See the following pages for more information:

How is it licensed?

Bindable LINQ is licensed under the New BSD license, making it free to use in both open source and commercial applications.

Upcoming Plans

We are currently planning what will be involved in version 1.0. See Plans for 1.0.
Last edited Jun 2 2008 at 2:48 PM by stovellp, version 19

 

Want to leave feedback?
Please use Discussions or Reviews instead.

Archived page comments (2)

Updating...
© 2006-2009 Microsoft | About CodePlex | Privacy Statement | Terms of Use | Code of Conduct | Version 2009.6.1.15196