Delete record with Oracle

Posts   
 
    
Wally
User
Posts: 285
Joined: 29-Aug-2007
# Posted on: 04-May-2009 15:52:59   

I feel a bit dump but is anybody can tell me what I do wrong because no records are being deleted...

foreach (EvenementLocLocResEntity evLocLocRes in loc.EvenementLocLocRes) { evLocLocRes.Delete(); }

confused

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 04-May-2009 17:43:24   

Please troubleshoot Turn on the dynamic query trace switch and check the generated SQL.

Wally
User
Posts: 285
Joined: 29-Aug-2007
# Posted on: 04-May-2009 20:07:42   

Thanks Walaa, it would have been a very nice idea. But I already red few parts of the documentation (again) where I think I found a solution. It sounds like the delete would not work because my entities were not fetched, but i'm not sure.

I wanted to delete the relation established between 2 entities on a relation m:n.

The way it worked was to create a new collection of the entity type of the m:n table and call deleteMulti with the appropriate predicate.


EvenementLocLocResCollection evenementLocLocResCollection = new EvenementLocLocResCollection();
evenementLocLocResCollection.DeleteMulti(EvenementLocLocResFields.LocalisationResultatId == loc.LocalisationResultatId);

I wonder how I can achieve that using direct DeleteMulti like this...


loc.EvenementLocLocRes.DeleteMulti(); 

Because previous code just do nothing on the database. What's the best way to delete ?

EvenementLocLocRes is the collection of entity that make my m:n relation between Loc and EvenementLoc

ie: Loc (1) <--> (m) EvenementLocLocRes (n) <--> (1) EvenementLoc

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 05-May-2009 03:51:44   

Wally wrote:

I wonder how I can achieve that using direct DeleteMulti like this...


loc.EvenementLocLocRes.DeleteMulti(); 

Because previous code just do nothing on the database. What's the best way to delete ?

That code should works too. If nothing happens it must be that the loc.EvenementLocLocRes is empty. The DeleteMulti() method which does not take any parameters works with the objects inside the collection and deletes them one by one from the persistent storage using an own transaction if the current collection isn't part of an existing transaction. (ref).

David Elizondo | LLBLGen Support Team