Reputation: 15817
I struggle to understand when to offset business logic to stored procedures and when to include in in .NET. I am developing a system that deletes information from other systems. Please see the code below:
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
Instead of going this I could create stored procedures in each of the databases. Is there criteria people use to decide when to use stored procedures?
Upvotes: 0
Views: 52
Reputation: 82136
It's pretty simple, anything related to the database that can be run at the DB end, should be run there.
There are some special cases were sometimes you need some extra logic but for the most part if its a common piece of DB logic and is executed frequently then it would be more efficient as a stored procedure.
Upvotes: 1