asp.net mvc 4 - Using same stored procedure across MVC controllers -
I am developing an MVC application, please tell me the best way to select a stored procedure.
- Loading a cando grid on page loads AutoBind (True)
- Select a record from the grid and showing details in another view below the grid . (This is working fine too)
- Now I am editing the information in the information below and saving the grid back (SP is calling here)
- Grid Loading with update dated details when saved.
Now my question is that I can share the same stored procedure for recording and loading the grid back. Am I missing out on concerns or after a few things. Please suggest the best way to do this.
No, you should use separate stored procedures to do this. Stored procedures (even in my opinion) must minimize the minimum required to complete their work. When talking about a single stored procedure that is responsible for both
UPDATE and
SELECT functions, you give potential introduction to very strange behavior.
As you technically can do this however
process create dbo.myobject_update_and_retrieve (@ UdpateParam1 varchar (25), @ UpdateParam2 integer, @UpdatedItemId integer) from Start update item SET UpdateParam1 = @ UpdateParam1, UpdateParam2 = @ UpdateParam2 where UpdatedItemId = @UpdatedItemId selection UpdateParam1, UpdateParam2 items end because
ExecuteReader intended
instead of calling
It is not desirable ExecuteNonQuery here. You lose some of the things provided by you by calling
ExecuteNonQuery to run
stored procedures based on, insert, update, delete .
It also makes units easy to test
I will recommend two different procedures as shown below
The process of making dbo.myobject_update (@ UdpateParam1 varchar (25), @ UpdateParam2 int, start as @UpdatedItemId int) UPDATE myobjects SET Col1 = @ UpdateParam1, Col2 = @ UpdateParam2 WHERE ID = @UpdatedItemId END
and as the start process dbo.myobject_retrieve Start Select Coll, Call 2, IID Foaim
Comments
Post a Comment