SaveEntityCollection and EntityState.Deleted

Posts   
 
    
alexdresko
User
Posts: 336
Joined: 08-Jun-2004
# Posted on: 10-Nov-2005 19:34:55   

I found this thread which seems to answer my question, but I'm not sure why LLBLGen doesn't work as expected:

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=3694

My example:


For Each entity as SomeEntity in LotsaEntities
   If (entity.SomeField = False) Then
      entity.Fields.State = EntityState.Deleted
   End If

Next

adapter.SaveEntityCollection(LotsaEntities)


Why doesn't SaveEntityCollection remove the entities marked as Deleted? Am I doing something wrong?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 10-Nov-2005 20:13:16   

Because that's not supported. If you want to delete an entity, call the methods which delete an entity or a group of entities. This to make sure you delete what you want to delete simple_smile

Frans Bouma | Lead developer LLBLGen Pro
alexdresko
User
Posts: 336
Joined: 08-Jun-2004
# Posted on: 10-Nov-2005 20:45:52   

Otis wrote:

Because that's not supported. If you want to delete an entity, call the methods which delete an entity or a group of entities. This to make sure you delete what you want to delete simple_smile

If anyone is curious, this worked.. (Generics rule)


Dim entitiesToDelete As New System.Collections.Generic.List(Of Integer)

For Each entity as SomeEntity in LotsaEntities
   If (entity.SomeField = False) Then
      entitiesToDelete.Add(entity.EntityId)
   End If
Next

Dim deleteBucket As New RelationPredicateBucket()
deleteBucket.PredicateExpression.Add(PredicateFactory.CompareRange(SomeEntityFieldIndex.EntityId, entitiesToDelete))

adapter.DeleteEntitiesDirectly("SomeEntity", entitiesToDelete)