Is there a simpler way exposing Stored Procedures with WCF Data Services?
There are numerous articles over internet that explain you how to expose a
stored procedure as OData via Wcf Data Services and Entity Framework. Here
is one example article:
http://dotnet.dzone.com/news/exposing-stored-procedure-wcf
The solution is to write something like this:
[WebGet]
public IQueryable<Course> GetCoursesOrderByTitle()
{
return CurrentDataSource
.GetCoursesOrderByTitle()
.AsQueryable();
}
Effectively you need to create a method and enumerate every single stored
procedure parameter in two places: as parameters to the method above and
then as parameters to the method on CurrentDataSource. And you need to
repeat this for every single stored procedure you are exposing. This above
is nothing but plumbing code. Any time a parameter changes or a type on a
parameter changes you need to remember to go here and update, as if
updating it in the EF model is not enough hassle.
I know that I can try and write code gen but I don't know a simple way of
doing this and inserting it in the build cycle.
Does anybody have a working solution to this problem? In my project I have
quite a big number of stored procedures exposed to the api and not a
single but several WCF Data services that expose them and the number of
these keeps growing as the API evolves. How to keep maintenance time for
these low?
No comments:
Post a Comment