C # Remove a problem with an object belonging to another object

We have two assemblies A and B, where B extends from A. B has a property of type A

If we have a record B in the database, and we delete A, which is used by B, the record will be deleted

How can we prevent this from happening in the code, because we will show the link to delete or not, if we can or cannot remove A. Since B always needs type A, and if A is used in the record B, A cannot be deleted.

We use NHibernate as an ORM.

+3
source share
2 answers

You can check relationships in sql Or triggers that you can use to prevent deletion

,

+1

ORM
.

+2

Source: https://habr.com/ru/post/1778067/


All Articles