WCF DataServices & the Processing Pipeline?

I spent quite a lot of time with WCF Data Services (‘Astoria’/’ADO.NET Data Services’ as it was) in its first iteration.

It’s a framework that I really like so I’m feeling a little guilty that I haven’t found time to completely revisit it as it becomes part of a ‘much bigger thing’ (i.e. OData) and as it got rev’d in .NET 4.0 and (from a client perspective) Silverlight 4.

I have been doing some of that revisiting in a piecemeal fashion though and there’s good material out there. For instance I came across articles such as Elisa’s and the main MSDN library page which give you enhancements such as;

  • the DataServiceCollection<T> type on the client side to do a tonne of binding goodness and auto-change tracking
  • server driven paging
  • obtaining a total row count for an entity set either with the data or on its own as a separate piece of data
  • client side projections (i.e. selecting just the columns of data that you want)
  • more flexibility around how you plug in your server side data in order so that you can expose;
    • Entity Framework (EDM) models
    • Reflection based models for LINQ to SQL and any other custom model where you know the “shape” of the model at compile time and can apply attributes to the codebase for the Reflection provider
    • Non-reflection based models including dynamic models via the new interfaces
  • improvements around BLOB support

But I realised that I missed something today when I was casting my eye over this great series of posts;

and I spotted something that I didn’t know about.

I had previously seen that you could hook into the Data Services client side pipeline – that is that the DataServiceContext supports a SendingRequest event that you could use to plug in to ( e.g. the article plugs in and adds an authorization header ).

But what I hadn’t previously seen that you could hook into the Data Services service side pipeline – that the DataService<T> has a property on it called ProcessingPipeline of type ProcessingPipeline with events for [Processing/Processed]Request and [Processing/Processed]Changeset.

I knew that you could write Query and Change interceptors but I had hoped for something more generic and I’d written back in 2008 that I was having trouble because;

“So far, I've not found any place to centralise this code and hook into the dispatch mechanism that Data Services is using”

Well – it looks like that centralised place is there in Data Services in .NET 4.0 and there’s a place to plug in code to the pipeline on the server – very glad to see it Smile

Now…back to that set of articles…