Search code examples
c#sql-servernhibernatearchitectureentity-relationship

C# Delete problem with an object relating to another object


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

If we have a record of B in de database and we delete A wich is used by B the record will be removed

How can we prevent this in code because we will show a delete link or not if we can or can't delete A. Because B always need a type of A and if A is in used by a record of B, A may not be removed.

We use NHibernate as ORM.


Solution

  • You can check relations in sql Or triggers witch you can use for prevent deleting

    And for the delete link i think you must check into the code and write a method for it