Hmm. I have an EntityCollection of objects, each of which has an EntityCollection of sub-objects (Members containing Events). I'm writing a data conversion app that is updating all events, but I have to go through Member to get some data that will help determine how to update the event. I'm trying to do a single update at the very end so that the entire update will be treated as a single transaction, but I cannot get anything to actually update in the DB (although I get no errors -- it acts like it works). I'm trying to do this (simplified):
EntityCollection members = new EntityCollection(new MemberEntityFactory());
IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.MemberEntity);
prefetchPath.Add(MemberEntity.PrefetchPathEvents);
DataAccessAdapter daa = new DataAccessAdapter();
daa.FetchEntityCollection(members, null, 0, null, prefetchPath);
// loop through all events for all members and convert data
daa.SaveEntityCollection(members, false, true);
The members themselves do not get updated (all events do), but it's my understanding that you will loop through all sub-objects looking for any that are dirty, regardless of whether or not the parent is dirty, right? Just to be sure, I tried manually setting member.IsDirty = true on each member, but that did not help.
The only way I can get it to work is to move the save into the member loop and call it after each set of events has been updated like so:
daa.SaveEntityCollection(member.Events, false, true);
This saves correctly to the DB, and will probably work for me as I will be testing it out beforehand anyway, but I would prefer a single transaction if possible. Am I missing something?
Thanks,
Brian