public override IObjectsDataSet CloneDirtyObjects(IObjectsDataSet rootDataSet)
        {
            var  clone = new UserProfileObjectsDataSet(rootDataSet as ObjectsDataSet);
            bool completed;

            foreach (var keyValue in this.UserProfileObjects.Where(o => o.Value.IsDirty || o.Value.IsMarkedForDeletion))
            {
                var cloneObject = (UserProfileDataObject)keyValue.Value.Clone(false);
                cloneObject.InternalObjectId = keyValue.Value.InternalObjectId;

                completed = false;
                while (!completed)
                {
                    completed = clone.UserProfileObjects.TryAdd(keyValue.Key, cloneObject);
                }
            }

            foreach (var keyValue in this.UserProfileObjectInternalIds
                     .Where(o => this.UserProfileObjects[o.Value].IsDirty || this.UserProfileObjects[o.Value].IsMarkedForDeletion))
            {
                completed = false;

                var count = 0;
                while (!completed && count++ < 15)
                {
                    completed = clone.UserProfileObjectInternalIds.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 UserProfileObjectsDataSet(rootDataSet as ObjectsDataSet);
            bool completed;

            foreach (var keyValue in this.UserProfileObjects)
            {
                var cloneObject = (UserProfileDataObject)keyValue.Value.Clone(false);
                cloneObject.InternalObjectId = keyValue.Value.InternalObjectId;

                completed = false;
                var count = 0;
                while (!completed && count++ < 15)
                {
                    completed = clone.UserProfileObjects.TryAdd(keyValue.Key, cloneObject);
                }
            }

            foreach (var keyValue in this.UserProfileObjectInternalIds)
            {
                completed = false;
                var count = 0;
                while (!completed && count++ < 15)
                {
                    completed = clone.UserProfileObjectInternalIds.TryAdd(keyValue.Key, keyValue.Value);
                }
            }



            return(clone);
        }