Shagohad
Shagohad

Reputation: 398

Call stored procedure with parameters using Web Api Odata

Is it possible to call Stored Procedure with parameters using Web Api Odata?. How can I achieve that?. My intention is call Web APi Odata function with two parameters to get results I'am expecting. I was thinking about using "Views", but unfortunately i have to pass parameters to get more specific results. Thanks for advise!

Upvotes: 1

Views: 7959

Answers (1)

lencharest
lencharest

Reputation: 2935

Expose your stored procedure as an unbound OData function. An OData function is invoked using GET with the parameters specified in the URI. For example:

GET http://host/SomeFunction(Param1=123,AnotherParam='a string')

You will need to declare the function as part of your OData configuration, and write a controller action method to implement the stored procedure invocation. Here's a tutorial to get you started: Actions and Functions in OData v4 Using ASP.NET Web API 2.2

Upvotes: 1

Related Questions