I have a WCF Data service
which uses the reflection provider to expose a data context. Now I need to implement some simple service methods (There are all actions. They don't have return values). I did some research with Google and also found a lot of posts.
But I never found something like an default implementation for the IDataServiceActionProvider
which for example works with attributes or something like this.
Now the question:
Do I really need to implement the IDataServiceActionProvider
by my own or is there something like ReflectionDataServiceActionProvider
?
This is probably not answer you want to hear, but I'm not aware of a default implementation of IDataServiceActionProvider.
You might want to take a look into creating your OData service using Web API instead of WCF Data Services; from my understanding, creating actions is much easier with Web API.
Some quick sample code taken from Alex's blog post to demonstrate the simplicity:
ActionConfiguration pullWheelie = modelBuilder.Entity<Motorcycle>().Action(“PullWheelie”);
pullWheelie.Parameter<int>(“ForSeconds”);
pullWheelie.Returns<bool>();
Alternatively, instead of creating an OData action, you could use WCF Data Services to create a "Service Operation" which is somewhat of a legacy actions/functions capability of OData. It's pretty easy to create one of these with WCF Data Services, but be aware that they'll be disappearing completely in OData v4. To create a service operation, you just need to create a method in your data source and annotate it with the WebGet
or WebInvoke
attribute. Once you configure the permissions for accessing the method in InitializeService
, your method will be invokable by clients. For details, see this documentation.