My code:
DataAccessAdapter adapter = new DataAccessAdapter();
GOrderEntity go = new GOrderEntity("2695cc08"); //orderid
EntityCollection ec = go.GorderGroup;
Where you fetch go entity?
foreach(GOrderGroupEntity gog in ec)
{
gog.IsNew=false; gog.ShipMethod=prodcode;
adapter.SaveEntity(gog);
}
I think isn't necessary gog.IsNew = false (the entities are fresh fetched). And even adater.SaveEntity as you can Save the entire collection at once.
I suggest you the next rewrite:
DataAccessAdapter adapter = new DataAccessAdapter();
GOrderEntity go = new GOrderEntity("2695cc08"); //orderid
IPrefetchPath2 path = new PrefetchPath2((int) EntityType.GOrderEntity);
path.Add(GOrderEntity.PrefetchPathGorderGroup);
path.Add(...)
// retrieve the graph
adapter.FetchEntity(go, path);
string prodcode = "UPS";
// update the collection
foreach(GOrderGroupEntity gog in go.GorderGroup)
{
gog.ShipMethod=prodcode;
}
// save recursive without refetch
adapter.SaveEntity(go, false, true);
And if you only want to update the prodcode, you can use this:
DataAccessAdapter adapter = new DataAccessAdapter();
// filter to update
IRelationPredicateBucket filter = new RelationPredicateBucket();
filter.Add(GOrderFields.IdGOrder == "2695cc08");
// new values to update
GorderGroupEntity newValues = new GorderGroupEntity();
newValues.ShipMethod = "UPS";
// make the update
adapter.UpdateEntitiesDirectly(newValues, filter);