Enforcing Database Constraints In Application Code

后端 未结 2 1317
悲哀的现实
悲哀的现实 2021-01-14 22:51

I\'m working on my first real asp.net web application and I\'m kind of stumped on the best place and method to trap and handle database constraint violations. Suppose I hav

2条回答
  •  Happy的楠姐
    2021-01-14 23:21

    I agree that it is the latter given your description of how you are using the database. It is really important to realize that even if you made a call from your business layer to validate every single possible constrain violation before doing an update/insert, a split second later the database state could change because of requests of other users and your update/insert could still fail.

提交回复
热议问题