Hello there,
I'm having problems deleting some records. I've got a loop going and it goes through all the motions, getting the ID number and doing the delete. However when I look at the DB table, all the records are still there! Can anyone tell me what i'm missing in my code?
Thanks,
Alan R
//Get List of Collections to be deleted
EntityCollection<ErcHeritageRelatedCollectionEntity> oldcollections = new EntityCollection<ErcHeritageRelatedCollectionEntity>();
// fetch them using a DataAccessAdapter instance
IRelationPredicateBucket filter = new RelationPredicateBucket();
filter.PredicateExpression.Add(ErcHeritageRelatedCollectionFields.ResourceId == ID);
filter.PredicateExpression.Add(ErcHeritageRelatedCollectionFields.DateAdded < timenow);
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
adapter.FetchEntityCollection(oldcollections, filter, 0, null);
//Now delete the collections
DataAccessAdapter adapter2 = new DataAccessAdapter(true);
foreach (IEntity2 entity2 in oldcollections)
{
int _delID = 0;
int.TryParse(entity2.Fields[0].CurrentValue.ToString(), out _delID);
ErcHeritageRelatedCollectionEntity record = new ErcHeritageRelatedCollectionEntity(_delID);
adapter2.DeleteEntity(record);
}
adapter2.CloseConnection();
}