stored-proceduresormdata-accesstelerik-open-access

Will I use stored procedures or direct write code in a mvc web project?Which is better?


My web project is using telerik dataaccess ORM,when I deal with the data,I can use stored procedures or direct write code.I find it is more efficient to use stored procedures.But some of my workmate say that using stored procedures is difficult to maintain, especially for some of the new recruits.Can anyone tell me when to use stored procedures and when direct write code in ORM better?


Solution

  • The whole idea of using an ORM is that you don't have to write much "raw" SQL code anymore - you work with the ORM layer to get back nice .NET objects from the database, and you work with those.

    However, if you have some extensive processing where you need to crunch through thousands or millions of rows, and in the end you just need one or two numerical values back (like an average and a deviation or something along those lines), then it probably makes more sense to do this extensive number crunching on the server inside a stored procedure, and just get back those few result values that you need. In this case, I'd use a stored procedure on the server - instead of pulling down millions of rows from the server to your application and computing those numbers locally. Just a matter of efficiency.