Last post Jul 20, 2015 04:53 AM by Krunal Parekh
Jul 18, 2015 09:52 AM|simonSM|LINK
I have stored procedures inside my database. I would like to create web api methods, which will return json string for each stored procedure result and accept parameters of stored procedures from my web client(jQuery, extjs).
As i know it could be done with entity framework automatically - it snifs database and creates controller methods for each procedure.
Is there some example(could be also book) how to do that - since I can't find any? Most of them are with code first or linq, tables only, repository pattern and similar...
Jul 18, 2015 10:47 AM|DeadTroll|LINK
While EF is newer and shinier its can be a 10 ton hammer when all you need is a tac hammer. If the only thing you need to do is access stored procs then I would suggest using Linq To SQL or Dapper. Nhibernate is another option but I'm not a fan. Dapper is
very light weight because its a micro framework. Linq To SQL is a bit heavier but still a touch faster than EF.
if you are sure you want to use EF, I'm assuming version 6 here then try this page to get you started
Jul 18, 2015 01:17 PM|simonSM|LINK
I have seen somewhere that entity framework creates web api controller methods automatically(which returns json string of procedure result by default to the client).
When you change Stored procedure and add additional filed, this field is automatically added to json result and send to client -all you have to do is refresh from DB(similar as entity framework works with CRUD operations with tables).
So, you don't need to code anything to get your result from stored procedure.
That is really nice to have. (since I already have a lot of coding on front end and database).
Is there some example how to do that? Could be dapper or anything else.
Jul 20, 2015 04:53 AM|Krunal Parekh|LINK
First of all I hope you are not talking about Scaffolding.
Also please see:
I think this might be of some help.
Please see: http://www.aspnetboilerplate.com/
Hope this helps.