コード例 #1
0
        public void DeleteAll()
        {
            command.Execute <User>();

            sqlExecutor
            .Verify(x => x.ExecuteNonQuery("DELETE FROM Users"));
        }
コード例 #2
0
ファイル: OptionController.cs プロジェクト: nelly2k/one
        public async Task <IActionResult> Delete([FromRoute] Guid storyId, [FromRoute] int id,
                                                 [FromServices] IDeleteCommand <Guid, int, Option> deleteOptionCommand)
        {
            await deleteOptionCommand.Execute(storyId, id);

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

            return(Ok());
        }
コード例 #4
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));
 }
コード例 #5
0
ファイル: OptionValueController.cs プロジェクト: nelly2k/one
        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());
        }
コード例 #6
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));
        }
コード例 #7
0
ファイル: DataBase.cs プロジェクト: seymourpoler/Gambon
 public void Delete <T>(
     dynamic condition = null) where T : class
 {
     deleteCommand.Execute <T>(condition: condition);
 }
コード例 #8
0
ファイル: DataDelete.cs プロジェクト: sndnvaps/Kerosene.ORM
        /// <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();
                }
            }
        }