public override IObjectsDataSet CloneDirtyObjects(IObjectsDataSet rootDataSet) { var clone = new VisitedPlaceObjectsDataSet(rootDataSet as ObjectsDataSet); bool completed; foreach(var keyValue in this.VisitedPlaceObjects.Where(o => o.Value.IsDirty || o.Value.IsMarkedForDeletion)) { var cloneObject = (VisitedPlaceDataObject) keyValue.Value.Clone(false); cloneObject.InternalObjectId = keyValue.Value.InternalObjectId; completed = false; while (!completed) { completed = clone.VisitedPlaceObjects.TryAdd(keyValue.Key, cloneObject); } } foreach(var keyValue in this.VisitedPlaceObjectInternalIds .Where(o => this.VisitedPlaceObjects[o.Value].IsDirty || this.VisitedPlaceObjects[o.Value].IsMarkedForDeletion)) { completed = false; var count = 0; while (!completed && count++ < 15) { completed = clone.VisitedPlaceObjectInternalIds.TryAdd(keyValue.Key, keyValue.Value); } } // CloneDirtyObjects is used to pass only dirty objects to server to save changes. Since indexes are not serialized, no need to clone them return clone; }
public override IObjectsDataSet Clone(IObjectsDataSet rootDataSet) { var clone = new VisitedPlaceObjectsDataSet(rootDataSet as ObjectsDataSet); bool completed; foreach(var keyValue in this.VisitedPlaceObjects) { var cloneObject = (VisitedPlaceDataObject) keyValue.Value.Clone(false); cloneObject.InternalObjectId = keyValue.Value.InternalObjectId; completed = false; var count = 0; while (!completed && count++ < 15) { completed = clone.VisitedPlaceObjects.TryAdd(keyValue.Key, cloneObject); } } foreach(var keyValue in this.VisitedPlaceObjectInternalIds) { completed = false; var count = 0; while (!completed && count++ < 15) { completed = clone.VisitedPlaceObjectInternalIds.TryAdd(keyValue.Key, keyValue.Value); } } foreach(var fkKeyValue in this.Country_FKIndex) { var iscompleted = false; var count2 = 0; while (!iscompleted && count2++ < 15) { iscompleted = clone.Country_FKIndex.TryAdd(fkKeyValue.Key, new List<int>()); } foreach (var pk in fkKeyValue.Value) { clone.Country_FKIndex[fkKeyValue.Key].Add(pk); } } foreach(var fkKeyValue in this.Place_FKIndex) { var iscompleted = false; var count2 = 0; while (!iscompleted && count2++ < 15) { iscompleted = clone.Place_FKIndex.TryAdd(fkKeyValue.Key, new List<int>()); } foreach (var pk in fkKeyValue.Value) { clone.Place_FKIndex[fkKeyValue.Key].Add(pk); } } foreach(var fkKeyValue in this.UserProfile_FKIndex) { var iscompleted = false; var count2 = 0; while (!iscompleted && count2++ < 15) { iscompleted = clone.UserProfile_FKIndex.TryAdd(fkKeyValue.Key, new List<int>()); } foreach (var pk in fkKeyValue.Value) { clone.UserProfile_FKIndex[fkKeyValue.Key].Add(pk); } } return clone; }