3
votes

Our team is evaluating using WCF Data Services (formerly ADO.NET Data Services), and have determined we'll have to create a Custom Data Service Provider. Where can we find a sample implementation of the two required interfaces: IDataServiceMetadataProvider and IDataServiceQueryProvider?

EDIT: Note that a "WCF Custom Data Service Provider" is not the same as an "ADO.NET Custom Data Provider."

EDIT: We have begun reverse-engineering using Reflector, but I would still appreciate it if somebody had a sample they would be willing to post!

6
Creating a custom ADO.NET provider is a difficult task. - scope_creep
What is the reasoning behind it, the usage scenario. In the 15 years i've been using ADO.net and ADO, I only ever saw 1 usage scenario, which required the construction of an ADO provider in 1999. There are providers for 99% of data available, in configuration from, from key/value pairs, csv, flat, relational, geo, spatial, blob, image, binary, the list is endless. I'm curious. The .net docs are much clearer that the windows DNA, COM muck that was on the go back then. That should make it easier. - scope_creep

6 Answers

3
votes

I've just implemented my first DataService with custom provider two weeks ago, and was on the verge of giving up (even after reading AlexJ's blog post on custom providers.).

Then I found that the custom provider toolkit makes this task quite easy. Have a look at the solution and the way the demo web service therein is implemented. Then alter that demo project to fit your needs. It's much easier that coding all this from scratch, and the toolkit is built with reusability in mind anyway.

0
votes

I'm not aware of any open source / public implementations; your best bet may be to use .NET Reflector against an existing implementation.

0
votes

The code that you require to write will be dependent upon your data source.

You may be able to save development effort by using the standard ADO.Net Data Services, and extending them where necessary.

Take a look at this link on injecting custom code into ADO.Net Data Services: http://weblogs.asp.net/cibrax/archive/2009/06/08/injecting-custom-logic-in-ado-net-data-services.aspx

There is also a link from that page that shows some implementation details.

0
votes

I assume MS used the WCF Data Service Custom Provider Interfaces when creating their SharePoint provider maybe we can find usage information by reflecting some SharePoint DLLs.

0
votes

The best way to accomplish this is by using the WCF Data Services Toolkit.

The author/maintainer of this project also has a few blog posts on its usage. He doesn't detail how to use all its features - but does give you a great introduction and examples of how to use it.

It essentially lets you expose any object as an OData feed by implementing a 'Repository' class. It handles all the reflection necessary to report back to the Data Services framework of what is the shape of your data.