The following generated code causes the entity to be marked dirty. This happens when an EntityCollection is bound to an UltraGrid. The collection is empty when bound. The field that is changed is LocationId which I believe is somehow set when the last statement is executed. It is 0 and IsChanged is false before last statement is executed, but is 3 and IsChanged is true after the last statement is executed.
private void SetupSyncSpecimenCollectionLocation(IEntity2 relatedEntity)
{
DesetupSyncSpecimenCollectionLocation(true);
if(relatedEntity!=null)
{
_specimenCollectionLocation = (SpecimenCollectionLocationEntity)relatedEntity;
_specimenCollectionLocation.ActiveContext = base.ActiveContext;
_specimenCollectionLocation.AfterSave+=new EventHandler(OnEntityAfterSave);
base.SetEntitySyncInformation("SpecimenCollectionLocation", _specimenCollectionLocation, CollectionLocationContactEntity.Relations.SpecimenCollectionLocationEntityUsingLocationId);
}
}
The reason I noticed this is that a template row is created and if I tab through it, it actually adds an entity to the collection. If I check for entity.IsNew and entity.IsDirty, I can filter these from being saved. Since I have not edited this entity at all I was wondering why it is marked IsDirty.
Thanks