0

我很难理解何时将业务逻辑偏移到存储过程以及何时包含在 .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

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

4

1 回答 1

1

这很简单,任何与数据库相关的可以在 DB 端运行的东西,都应该在那里运行。

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

于 2013-09-11T21:19:10.830 回答