The important part to take notice of here is this, where you instantiate a connection to your Unpublished tables
When you need to Unpublish data you should
new DataConnection(PublicationScope.Unpublished)
adding data here will never ever be avaliable in the Published scope, and you there need to add data to both PublicationScope.Published and PublicationScope.Unpublished. Usually i do a foreach-loop over all possible PublicationScopes and then run the same code.When you need to Unpublish data you should
- Delete it from Published scope
- set PublicationStatus on the item in Unpublished scope to "unpublished"