I wanted to find out if there was a clean way to save the parent object and have it save the children in the following structure:
Person -> PersonAddress -> Address
Here is the sample code.
DataAccessAdapter adapter = new DataAccessAdapter(connectionString);
PersonEntity person = new PersonEntity(4);
PrefetchPath2 prePath = new PrefetchPath2((int)EntityType.PersonEntity);
prePath.Add(PersonEntity.PrefetchPathAddressCollectionViaPersonAddress);
adapter.FetchEntity(person, prePath);
person.AddressCollectionViaPersonAddress.IsReadOnly = false;
// add an address
AddressEntity address = new AddressEntity();
address = person.AddressCollectionViaPersonAddress.AddNew();
address.AddressTypeId = 1;
address.Line1 = "Bla";
address.Line2 = "Bla";
address.Line3 = "Bla";
adapter.SaveEntity(person, true, true);
If I SaveEntityCollection it saves the new Address but not the PersonAddress?