存储过程和类

时间:2013-09-11 21:09:09

标签: .net stored-procedures

我很难理解何时将业务逻辑偏移到存储过程以及何时包含在.NET中。我正在开发一个删除其他系统信息的系统。请参阅以下代码:

Public Interface Deleteable
    Sub Delete()

End Interface

Public Class Database1
    Implements Deleteable

    Public Sub Delete() Implements Deleteable.Delete
        'Logic to implement deletion from system 1 i.e. 1) can I delete? and 2) If I can delete then execute delete.

    End Sub
End Class

Public Class Database2
    Implements Deleteable

    Public Sub Delete() Implements Deleteable.Delete
        'Logic to implement deletion from system 1 i.e. 1) can I delete? and 2) If I can delete then execute delete.

    End Sub
End Class

Public Class Database3
    Implements Deleteable

    Public Sub Delete() Implements Deleteable.Delete
        'Logic to implement deletion from system 1 i.e. 1) can I delete? and 2) If I can delete then execute delete.

    End Sub
End Class

我可以在每个数据库中创建存储过程,而不是这样做。是否有人用来决定何时使用存储过程的标准?

1 个答案:

答案 0 :(得分:1)

这很简单,任何与数据库相关的任何事情都可以在那里运行 运行在那里。

有些特殊情况有时你需要一些额外的逻辑,但是大多数情况下,如果它是一个常见的DB逻辑并经常执行,那么它作为存储过程会更有效。