Print Page | Close Window

Deleting an Object

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1086
Printed Date: 28-Jul-2025 at 9:14pm


Topic: Deleting an Object
Posted By: msosa
Subject: Deleting an Object
Date Posted: 06-Feb-2009 at 6:23am
I have the following database structure:
 
Table: User
Fields: Id, Name, Password, Status
 
Table: Rol
Fields: Id, Description
 
Table UserRol
Fields: UserId, RolId
 
So, I mapped those tables to devforce objects. Now, I can insert or update the objects and then calling SaveChanges() to the manager, everithing works all right.
 
The problem that I'm facing is that when I want to delete an User object, witch has some roles asigned and call SaveChanges(), the following error arises:
 
Save failed - The statement has been terminated.
The DELETE statement conflicted with the REFERENCE constraint "FK_UsuarioRol_Usuario"
 
The problem, I presume, is that the persistence engine is not deleting the related rows in UsuarioRol table, so when tries to delete the User the constraint error apperars... Is this by desing? What should I do?
 
Thanks.



Replies:
Posted By: davidklitzke
Date Posted: 06-Feb-2009 at 8:33am
IdeaBlade does not normally automatically delete related entities.  For example, if I delete an Order, it is probably incorrect to delete the Customer associated with that Order. Therefore, in most cases, you must delete the related entities yourself.
 
 There are some exceptions to this rule (see the Intermediate tutorial on "Cascading Deletes").



Print Page | Close Window