This project is read-only.

Delete ContentItem does not delete Part Record

Topics: Customizing Orchard, Writing modules
Mar 27, 2012 at 4:34 PM

I notice when i delete a content item using


it does not delete the existing record of whatever parts attached to this content item. For example, the AutoroutePartRecord and TitlePartRecord.

Is there any reason to keep these records? If not i guess i'll need to delete those manually from repository.

Mar 27, 2012 at 8:02 PM

That's the design: we only do soft deletes.

Mar 27, 2012 at 9:30 PM

If you do want to delete the content part when a content item is being removed, you can write a content handler that overrides the Remove method. From within that method, you could easily remove the part record.



public class MyPartHandler:ContentHandler
        private readonly IRepository<MyPartRecord> _repository;

        public MyPartHandler(IRepository<MyPartRecord> repository ) {
            _repository = repository;

        protected override void Removed(RemoveContentContext context)
            var myPart = context.ContentItem.As<MyPart>();

            if(myPart != null)


Mar 28, 2012 at 6:46 AM

thanks! It was giving me problems because one of the column is unique. If the existing record is not deleted, i cant create another new record with the same value.