Entity Deletion

Posts   
 
    
CliffH
User
Posts: 52
Joined: 03-May-2006
# Posted on: 18-Sep-2006 18:19:32   

Trying to delete a single child entity from a n:m relationship, result of adapter.DeleteEntity() is true, correct SQL is generated but the entity still sticks around. Any ideas on why this should be ?

DataAccessAdapter adapter = new DataAccessAdapter(); // bookinglock_id is PK, identity column, previously persisted entity BookingLockEntity bookinglock = new BookingLockEntity( bookinglock_id ); adapter.FetchEntity( bookinglock );

adapter.StartTransaction( IsolationLevel.ReadCommitted, "Unlock Booking"); try { bool IsDeleted = adapter.DeleteEntity( bookinglock ); adapter.CloseConnection(); } catch { adapter.Rollback(); throw; } adapter.CloseConnection();

Generated Sql query: Query: DELETE FROM [dbname].[dbo].[BookingLock] WHERE ( [dbname].[dbo].[BookingLock].[BookingLock_ID] = @BookingLock_ID1) Parameter: @BookingLock_ID1 : Int16. Length: 0. Precision: 5. Scale: 0. Direction: Input. Value: 18.

Method Exit: CreateSingleTargetDeleteDQ(3) Method Exit: CreateDeleteDQ(4)

Rogelio
User
Posts: 221
Joined: 29-Mar-2005
# Posted on: 18-Sep-2006 18:45:42   

Hi,

Does the deleted record is in the DB after you delete it?

CliffH
User
Posts: 52
Joined: 03-May-2006
# Posted on: 18-Sep-2006 19:22:43   

Yes it is I'm afraid.

Tried various methods with Adapter. Most frustrating. Initially, IsNew, IsDirty are false. After deletion, entity state is Deleted, IsDeleted is false, DML generated is what you would expect.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 18-Sep-2006 20:31:16   

The entity OBJECT isn't removed, you've to do that yourself (or let it go outof scope). Is the row deleted from the db table or not?

Frans Bouma | Lead developer LLBLGen Pro
CliffH
User
Posts: 52
Joined: 03-May-2006
# Posted on: 19-Sep-2006 02:25:34   

oops, omitted adapter.Commit();

Apologies.