我是否会在mvc web项目中使用存储过程或直接编写代码?哪个更好? [英] Will I use stored procedures or direct write code in a mvc web project?Which is better?

查看:72
本文介绍了我是否会在mvc web项目中使用存储过程或直接编写代码?哪个更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的web项目正在使用telerik dataaccess ORM,当我处理数据时,我可以使用存储过程或直接编写代码。我发现使用存储过程更有效。但是我的一些同事说使用存储过程很难维护,特别是对于一些新员工。任何人都可以告诉我何时使用存储过程以及何时直接在ORM中编写代码更好?

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?

推荐答案

不同的程序员对这个话题有不同的看法。



我更喜欢使用存储过程有两个主要原因:



1.数据库的结构对调用者是隐藏的。

调用者只知道过程的格式。

这意味着数据库结构可以随时改变只要SP以相同的方式返回答案并且不改变输入。

客户端根本不需要改变。

这实际上是数据库管理e asier。



2.在不同的数据库之间切换更容易

假设您有两个工厂,每个工厂有一个数据库,每个数据库具有相同的功能。

这两个数据库是独立维护的,甚至可以使用不同的版本,一个使用MySQL,一个使用Oracle。

通过使用存储过程,客户端软件可以保留相同而且只需要一些配置。



主要缺点是可能需要创建相当多的存储过程,并且还需要正确记录。 />
和COM中的接口一样,你永远不应该改变程序的格式。
Different programmers have different opinions about this topic.

I prefer to use stored procedures for two main reasons:

1. The structure of the database is hidden from the caller.
The caller only knows the format of the procedure.
This means that the database structure can change at any time as long as the SP returns the answer in the same way and doesn't change the input.
The client doesn't need to change at all.
This actually makes database administration easier.

2. It is easier to switch between different databases
Let's say you have two factories with one database each with the same functionality.
The two databases are maintained independently and can even be using different flavors, one use MySQL and one use Oracle.
By using stored procedures the client software can be kept the same and just some configuration is necessary.

The main drawback is that it can be quite a few stored procedures to create and they also need to be properly documented.
And as with interfaces in COM, you should never change the format of the procedure.


这篇关于我是否会在mvc web项目中使用存储过程或直接编写代码?哪个更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆