recursive save

Posts   
 
    
rarandas
User
Posts: 3
Joined: 11-May-2005
# Posted on: 10-Oct-2005 17:17:44   

I have a problem using dataadapter... When i try to recursive save an entity with an EntityCollection that it´s entity was deleted from database, the new itens of EntityCollection is not saved in database;

What i have to do? I have already tryied to flag as isnew, but did not work well

Example:


if(!Bolsa.IsNew)

{
                                    this.DataAccessAdapter.DeleteEntitiesDirectly("InsumoEntity",   Bolsa.GetRelationInfoInsumoCollection());
    this.DataAccessAdapter.DeleteEntitiesDirectly("ItemOrMaEntity", Bolsa.OrdemManipulacao.GetRelationInfoItemOrMaCollection());                                
}

for(int i = Bolsa.InsumoCollection.Count -1; i<=0;i--)
{
    InsumoEntity Insumo = (InsumoEntity)Bolsa.InsumoCollection[ i];
                            
Insumo.IsNew = false;                           
    Insumo.Bolsa = null;
    Insumo.Bolsa = Bolsa;
    Insumo.IsNew = true;
}
this.DataAccessAdapter.SaveEntity(Bolsa, true, null, true);                     

thank´s

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 11-Oct-2005 15:39:02   

The for loop will never be invoked, since the condition i<=0, should have been i>=0