DLinq and WPF
On the first WPF Proof of Concept we had a bit of a struggle with data binding.
WPF has a very strong data-binding model and it’s important to play to the strengths of that model. So, simply writing SQL queries and mapping to a DataSet is possible, but doesn’t play to the strengths of WPF (ObservableCollections and so on).
So on the second engagement, being a fan of the Castle Project and NHibernate I used the ActiveRecord implementation to build the object mapping layer. A bit of jiggery-pokery is needed to get AR running with generics, and then more was needed to return ObservableCollections which felt a bit forced and seemed to be leading me into trouble...
So then I thought that seeing as we’re using several betas on the project, let’s chuck another one in and use Linq (specifically DLinq). And it worked a treat! Because the mappings automatically return objects implementing INotifyChangedProperty and therefore ObservableCollection<T> collections, it’s ideal for binding to a WPF application. We can simply use the returned information directly or wrap the collection in a CollectionView for sorting and/or filtering.
The current Linq CTP (May 2006) includes a nice visual designer if you’re using the full Visual Studio 2005 product, but if you can handle manual work, then it works fine in Express too. It handles associations and inheritance of objects though isn’t what you’d consider a full O/RM layer at the moment. (Having said that, it’ll broadly do the trick.) Linq takes advantage of new C#3.0 language features such as lambda functions (natural progression of anonymous delegates) to provide an intuitive and flexible querying syntax.
Well worth a look just for the fun of it. I’d say that if you’re working with WPF and exposing data to the application, then you must consider it – even at this early stage in its life.