Friday 28 March 2014

Stored Procedures

Store Procedures are similar to methods but are stored inside the database. Store Procedures contains SQL code that can manipulate data in ways that would be difficult using C#. In a team environment store procedures are usually written by the DBA.

Store Procedures can have arguments and return values just like any other method. Store Procedures can do everything LINQ can do and usually be faster and more efficient. Using Store Procedures for everything might seem ideal but having hundred's of store procedures in a database often becomes unmanageable and difficult to maintain. I recommend using LINQ for simple everyday queries and store procedures for anything more complicated or if you see performance issues.

Using Store Procedures centralizes your SQL code on the database server and makes it easier to maintain your code if the database changes.

No comments:

Post a Comment