/// <summary>
        /// Performs the LSM operation on the source shard.
        /// </summary>
        /// <param name="ts">Transaction scope.</param>
        /// <returns>Result of the operation.</returns>
        public override IStoreResults DoLocalSourceExecute(IStoreTransactionScope ts)
        {
            IStoreResults result;

            if (_updateLocation)
            {
                result = ts.ExecuteOperation(
                    StoreOperationRequestBuilder.SpBulkOperationShardMappingsLocal,
                    StoreOperationRequestBuilder.RemoveShardMappingLocal(
                        this.Id,
                        false,
                        _shardMap,
                        _mappingSource));
            }
            else
            {
                result = ts.ExecuteOperation(
                    StoreOperationRequestBuilder.SpBulkOperationShardMappingsLocal,
                    StoreOperationRequestBuilder.UpdateShardMappingLocal(
                        this.Id,
                        false,
                        _shardMap,
                        _mappingSource,
                        _mappingTarget));
            }

            // We need to treat the kill connection operation separately, the reason
            // being that we cannot perform kill operations within a transaction.
            if (result.Result == StoreResult.Success && _fromOnlineToOffline)
            {
                this.KillConnectionsOnSourceShard();
            }

            return(result);
        }
        /// <summary>
        /// Performs the undo of LSM operation on the source shard.
        /// </summary>
        /// <param name="ts">Transaction scope.</param>
        /// <returns>Result of the operation.</returns>
        public override IStoreResults UndoLocalSourceExecute(IStoreTransactionScope ts)
        {
            DefaultStoreMapping dsmSource = new DefaultStoreMapping(
                _mappingSource.Id,
                _shardMap.Id,
                new DefaultStoreShard(
                    _mappingSource.StoreShard.Id,
                    this.OriginalShardVersionRemoves,
                    _shardMap.Id,
                    _mappingSource.StoreShard.Location,
                    _mappingSource.StoreShard.Status),
                _mappingSource.MinValue,
                _mappingSource.MaxValue,
                _mappingSource.Status,
                _lockOwnerId);

            if (_updateLocation)
            {
                return(ts.ExecuteOperation(
                           StoreOperationRequestBuilder.SpBulkOperationShardMappingsLocal,
                           StoreOperationRequestBuilder.AddShardMappingLocal(
                               this.Id,
                               true,
                               _shardMap,
                               dsmSource)));
            }
            else
            {
                DefaultStoreMapping dsmTarget = new DefaultStoreMapping(
                    _mappingTarget.Id,
                    _shardMap.Id,
                    new DefaultStoreShard(
                        _mappingTarget.StoreShard.Id,
                        this.OriginalShardVersionRemoves,
                        _shardMap.Id,
                        _mappingTarget.StoreShard.Location,
                        _mappingTarget.StoreShard.Status),
                    _mappingTarget.MinValue,
                    _mappingTarget.MaxValue,
                    _mappingTarget.Status,
                    _lockOwnerId);

                return(ts.ExecuteOperation(
                           StoreOperationRequestBuilder.SpBulkOperationShardMappingsLocal,
                           StoreOperationRequestBuilder.UpdateShardMappingLocal(
                               this.Id,
                               true,
                               _shardMap,
                               dsmTarget,
                               dsmSource)));
            }
        }