/// <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)
 {
     return(ts.ExecuteOperation(
                StoreOperationRequestBuilder.SpBulkOperationShardMappingsLocal,
                StoreOperationRequestBuilder.AddShardMappingLocal(
                    this.Id,
                    false,
                    _shardMap,
                    _mapping)));
 }
 /// <summary>
 /// Performs the LSM operation on the target shard.
 /// </summary>
 /// <param name="ts">Transaction scope.</param>
 /// <returns>Result of the operation.</returns>
 public override IStoreResults DoLocalTargetExecute(IStoreTransactionScope ts)
 {
     Debug.Assert(_updateLocation);
     return(ts.ExecuteOperation(
                StoreOperationRequestBuilder.SpBulkOperationShardMappingsLocal,
                StoreOperationRequestBuilder.AddShardMappingLocal(
                    this.Id,
                    false,
                    _shardMap,
                    _mappingTarget)));
 }
        /// <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)));
            }
        }