public void UseSqlServer()
 {
     this._createCommand = new SqlServerCreateCommand();
     this._updateCommand = new SqlServerUpdateCommand();
     this._findCommand   = new SqlServerFindCommand();
     this._deleteCommand = new SqlServerDeleteCommand();
 }
Beispiel #2
0
        public QuickPadCommands(
            IShowGoToCommand <TStorageFile, TStream> showGotoCommand
            , IShareCommand <TStorageFile, TStream> shareCommand
            , ICutCommand <TStorageFile, TStream> cutCommand
            , ICopyCommand <TStorageFile, TStream> copyCommand
            , IPasteCommand <TStorageFile, TStream> pasteCommand
            , IDeleteCommand <TStorageFile, TStream> deleteCommand
            , IContentChangedCommand <TStorageFile, TStream> contentChangedCommand
            , IEmojiCommand <TStorageFile, TStream> emojiCommand
            , ICompactOverlayCommand <TStorageFile, TStream> compactOverlayCommand
            , IRateAndReviewCommand <TStorageFile, TStream> rateAndReviewCommand)
        {
            _commands = this;

            ShareCommand          = shareCommand;
            CutCommand            = cutCommand;
            CopyCommand           = copyCommand;
            PasteCommand          = pasteCommand;
            DeleteCommand         = deleteCommand;
            ContentChangedCommand = contentChangedCommand;
            EmojiCommand          = emojiCommand;
            CompactOverlayCommand = compactOverlayCommand;
            RateAndReviewCommand  = rateAndReviewCommand;
            ShowGoToCommand       = showGotoCommand;
        }
Beispiel #3
0
        public async Task <IActionResult> Delete([FromRoute] Guid storyId, [FromRoute] int id,
                                                 [FromServices] IDeleteCommand <Guid, int, Option> deleteOptionCommand)
        {
            await deleteOptionCommand.Execute(storyId, id);

            return(Ok());
        }
Beispiel #4
0
        public async Task <IActionResult> Delete([FromRoute] Guid id,
                                                 [FromServices] IDeleteCommand <Guid, Story> storyDeleteCommand)
        {
            await storyDeleteCommand.Execute(id);

            return(Ok());
        }
Beispiel #5
0
 public T Delete <T>(IDeleteCommand <T> command)
 {
     if (command.RequiresTransaction && _transaction == null)
     {
         throw new Exception($"The command {command.GetType()} requires a transaction");
     }
     return(Retry.Invoke(() => command.Execute(_connection, _transaction), _options));
 }
 public DeleteCommandTests()
 {
     sqlExecutor = new Mock <ISqlExecutorWithGeneric>();
     sqlBuilder  = new SqlBuilder();
     command     = new DeleteCommand(
         sqlBuilder: sqlBuilder,
         sqlExecutor: sqlExecutor.Object);
 }
Beispiel #7
0
        public async Task <bool> Handle(IDeleteCommand <T> command)
        {
            var filter = command.FilterDefinition();

            var actionResult = await Collection
                               .DeleteOneAsync(filter);

            return(actionResult.IsSuccess());
        }
 public UserService(IQuery <UserData, User> query,
                    ICreateCommand <UserData> createCommand,
                    IUpdateCommand <UserData> updateCommand,
                    IDeleteCommand <UserData> deleteCommand)
 {
     _query         = query;
     _createCommand = createCommand;
     _updateCommand = updateCommand;
     _deleteCommand = deleteCommand;
 }
Beispiel #9
0
 public RoleService(IQuery <RoleData, Role> query,
                    ICreateCommand <RoleData> createCommand,
                    IUpdateCommand <RoleData> updateCommand,
                    IDeleteCommand <RoleData> deleteCommand)
 {
     _query         = query;
     _createCommand = createCommand;
     _updateCommand = updateCommand;
     _deleteCommand = deleteCommand;
 }
Beispiel #10
0
        public async Task <IActionResult> Delete([FromRoute] Guid storyId,
                                                 [FromRoute] int featureId,
                                                 [FromRoute] int optionId,
                                                 [FromRoute] OptionValueType type,
                                                 [FromServices] IDeleteCommand <Guid, int, int, OptionValueType, OptionValue> deleteCommand)
        {
            await deleteCommand.Execute(storyId, featureId, optionId, type);

            return(Ok());
        }
Beispiel #11
0
        /// <summary>
        /// Invoked when disposing or finalizing this instance.
        /// </summary>
        /// <param name="disposing">True if the object is being disposed, false otherwise.</param>
        protected override void OnDispose(bool disposing)
        {
            try { if (_Command != null)
                  {
                      _Command.Dispose();
                  }
            }
            catch { }

            _Command = null;

            base.OnDispose(disposing);
        }
Beispiel #12
0
 private DataBase(
     ISelectCommand selectCommand,
     IInsertCommand insertCommand,
     IDeleteCommand deleteCommand,
     IUpdateCommand updateCommand,
     ISqlExecutorWithGeneric sqlExecutor)
 {
     this.selectCommand = selectCommand;
     this.insertCommand = insertCommand;
     this.deleteCommand = deleteCommand;
     this.updateCommand = updateCommand;
     this.sqlExecutor   = sqlExecutor;
 }
Beispiel #13
0
        public string GenerateSqlCommand <TEntity, TParams>(IDeleteCommand <TEntity, TParams> command, IQueryMetadata metadata)
        {
            var commandText = new StringBuilder();

            // Generate 'delete from ...'
            commandText
            .Append("delete from ")
            .Append(Quoter.QuoteTableName(metadata.TableSchema, metadata.TableName));

            // Generate 'where ...'
            commandText.Append(" where ");
            command.Predicate.GenerateWhereClause(commandText, Quoter, metadata, ParameterSyntaxType.None);

            return(commandText.ToString());
        }
Beispiel #14
0
        /// <summary>
        /// Generates a delete core command for the given entity, or returns null if such
        /// command cannot be generated for whatever reasons.
        /// </summary>
        internal static IDeleteCommand GenerateDeleteCommand(this IUberMap map, object entity)
        {
            if (entity == null)
            {
                return(null);
            }
            if (map == null || map.IsDisposed || !map.IsValidated)
            {
                return(null);
            }

            IDeleteCommand cmd = null;

            MetaEntity meta = MetaEntity.Locate(entity, create: true); if (meta.Record == null)
            {
                var record = new Core.Concrete.Record(map.Schema);
                map.WriteRecord(entity, record);
                meta.Record = record;
            }

            var id = map.ExtractId(meta.Record);

            if (id != null)
            {
                cmd = map.Link.Engine.CreateDeleteCommand(map.Link, x => map.Table);
                if (map.Discriminator != null)
                {
                    cmd.Where(map.Discriminator);
                }

                var tag = new DynamicNode.Argument("x");
                for (int i = 0; i < id.Count; i++)
                {
                    var left = new DynamicNode.GetMember(tag, id.Schema[i].ColumnName);
                    var bin  = new DynamicNode.Binary(left, ExpressionType.Equal, id[i]);
                    cmd.Where(x => bin);
                    left.Dispose();
                    bin.Dispose();
                }
                tag.Dispose();
                id.Dispose();
            }

            return(cmd);
        }
Beispiel #15
0
        //TODO: update this to return a type showing what objects got deleted e.g. IObjectId[]
        //the "reuest" dataset is assumed to have the Object ID values. However,
        //an extended implementation might send a query dataset and this method will query the DB and generate multiple Object IDs
        //Example: the request dataset has a date range, wild-card or SOP Class UID...
        public DCloudCommandResult Delete
        (
            fo.DicomDataset request,
            ObjectQueryLevel level
        )
        {
            DCloudCommandResult deleteResult  = null;
            IDeleteCommand      deleteCommand = CommandFactory.CreateDeleteCommand( );
            DeleteCommandData   deleteData    = new DeleteCommandData( )
            {
                Instances = new List <ObjectId> ( )
                {
                    new ObjectId(request)
                },
                DeleteLevel = level
            };

            return(deleteResult = deleteCommand.Execute(deleteData));
        }
Beispiel #16
0
 public DeleteCommand(IDeleteCommand command)
 {
     fullPath = command.FullPath;
 }
Beispiel #17
0
 /// <summary>
 /// Add From command to query
 /// </summary>
 /// <param name="deleteCommand">Delete command instance</param>
 /// <param name="table">Table name</param>
 /// <returns></returns>
 public static IFromCommand From(this IDeleteCommand deleteCommand, string table)
 => deleteCommand.To((s, p) => new FromCommand(s, p, table));
Beispiel #18
0
 public DeleteCommand(IDeleteCommand command)
 {
     fullPath = command.FullPath;
 }
Beispiel #19
0
 /// <summary>
 /// Add From command to query
 /// </summary>
 /// <param name="deleteCommand">Delete command instance</param>
 /// <param name="table">Table name</param>
 /// <returns></returns>
 public static IFromCommand From(this IDeleteCommand deleteCommand, string table)
 => deleteCommand is IFromCommand command?command.FromCommand(table) : null;
Beispiel #20
0
        /// <summary>
        /// Invoked to execute this operation.
        /// </summary>
        internal void OnExecute(object origin = null)
        {
            lock (Repository.MasterLock)
            {
                List <object>  list   = null;
                ChangeEntry    change = null;
                IDeleteCommand cmd    = null;

                DebugEx.IndentWriteLine("\n- Preparing 'Delete({0})'...", MetaEntity);
                try
                {
                    list = MetaEntity.GetRemovedChilds(forgetRemoved: true);
                    foreach (var obj in list)
                    {
                        if (obj == null)
                        {
                            continue;
                        }
                        if (object.ReferenceEquals(obj, origin))
                        {
                            continue;
                        }
                        var type = obj.GetType(); if (!type.IsClass && !type.IsInterface)
                        {
                            continue;
                        }

                        var meta = MetaEntity.Locate(obj);
                        var map  = meta.UberMap ?? Repository.LocateUberMap(type);
                        if (map == null)
                        {
                            throw new NotFoundException("Cannot find map for type '{0}'.".FormatWith(type.EasyName()));
                        }

                        var op = map.Delete(obj);
                        try { ((IUberOperation)op).OnExecute(origin: Entity); }
                        finally { op.Dispose(); }
                    }
                    list.Clear(); list = null;

                    list = MetaEntity.GetDependencies(Map, MemberDependencyMode.Child);
                    foreach (var obj in list)
                    {
                        if (obj == null)
                        {
                            continue;
                        }
                        if (object.ReferenceEquals(obj, origin))
                        {
                            continue;
                        }
                        var type = obj.GetType(); if (!type.IsClass && !type.IsInterface)
                        {
                            continue;
                        }

                        var meta = MetaEntity.Locate(obj);
                        var map  = meta.UberMap ?? Repository.LocateUberMap(type);
                        if (map == null)
                        {
                            throw new NotFoundException("Cannot find map for type '{0}'.".FormatWith(type.EasyName()));
                        }

                        var op = map.Delete(obj);
                        try { ((IUberOperation)op).OnExecute(origin: Entity); }
                        finally { op.Dispose(); }
                    }
                    list.Clear(); list = null;

                    cmd = Map.GenerateDeleteCommand(Entity);
                    if (cmd != null)
                    {
                        DebugEx.IndentWriteLine("\n- Executing '{0}'...", cmd);
                        try
                        {
                            MetaEntity.ValidateRowVersion();
                            int n = cmd.Execute();
                        }
                        finally { DebugEx.Unindent(); }
                    }
                    Map.Detach(Entity);

                    change = new ChangeEntry(ChangeType.Delete, Map, Entity);
                    Repository.ChangeEntries.Add(change);

                    list = MetaEntity.GetDependencies(Map, MemberDependencyMode.Parent);
                    foreach (var obj in list)
                    {
                        if (obj == null)
                        {
                            continue;
                        }
                        if (object.ReferenceEquals(obj, origin))
                        {
                            continue;
                        }
                        var type = obj.GetType(); if (!type.IsClass && !type.IsInterface)
                        {
                            continue;
                        }

                        var meta = MetaEntity.Locate(obj);
                        var map  = meta.UberMap ?? Repository.LocateUberMap(type);
                        if (map == null)
                        {
                            throw new NotFoundException("Cannot find map for type '{0}'.".FormatWith(type.EasyName()));
                        }

                        change = new ChangeEntry(ChangeType.Refresh, map, obj);
                        Repository.ChangeEntries.Add(change);
                    }
                }
                finally
                {
                    if (cmd != null)
                    {
                        cmd.Dispose();
                    }
                    cmd = null;
                    if (list != null)
                    {
                        list.Clear();
                    }
                    list = null;
                    DebugEx.Unindent();
                }
            }
        }