EntityCollection v.s. EntityCollection<ScItem>

Posts   
 
    
Posts: 12
Joined: 30-Nov-2007
# Posted on: 30-Nov-2007 08:01:39   

Hi, all.. simple_smile There is a sub EntityCollection<ScItemEntity> depend on Entity Sc. I can write as like as

foreach (ScItemEntity entity in Sc.ScItem)
   entity.SaveFields();

And if there is another sub EntityCollection<PoItemEntity> depend on Entity Po I can write as like as

foreach (PoItemEntity entity in Po.PoItem)
   Entity.SaveFields();

but I should write the independent source to do that job.

because I can't convert EntityCollection<ScItemEntity> or EntityCollection<PoItemEntity> to a normal type.

How can I design a common function that can do it ? thank you.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 30-Nov-2007 10:26:21   

Would you please try the following code:

private void SaveFields(IEntityCollection collection)
{
    foreach (EntityBase entity in collection)
    {
        entity.SaveFields();
    }
}

And then you can call the above method, passung Sc.ScItem or Po.PoItem.

Posts: 12
Joined: 30-Nov-2007
# Posted on: 30-Nov-2007 10:45:58   

YES, thank you , it's done!!