New Posts New Posts RSS Feed: Deleting an Object
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Deleting an Object

 Post Reply Post Reply
Author
msosa View Drop Down
Newbie
Newbie
Avatar

Joined: 04-Feb-2009
Posts: 6
Post Options Post Options   Quote msosa Quote  Post ReplyReply Direct Link To This Post Topic: Deleting an Object
    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.
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post 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").


Edited by davidklitzke - 06-Feb-2009 at 8:34am
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down