Delete comments
Sitefinity CMS allows you to delete a single comment or a group of comments through the Comments API.
When deleting a comment, you must perform the following:
    - Get an instance of the comments service by using the SystemManager's GetCommentsService method.
- Delete the comment using the DeleteComment method of the comments service. The method expects the comment key as a parameter.
 
Consider the code sample below:
 
When deleting multiple comments, follow the steps below:
    - Get an instance of the comments service using the SystemManager's GetCommentsService method.
- Delete all comments using the DeleteComments method of the comments service. The methods expects a collection of comment keys as a parameter.
Consider the code sample below:
 
 
In case you  need to delete programmatically all comments for a specific content type, for example News, follow the steps below:
    - Get an instance of the comments service.
 Use the GetCommentsService method of the SystemManager.
- To find all comments related to News, you use the CommentFilter and add NewsItem full type name as a criteria. 
 Thus, you can use the GetComments method and pass the filter as an argument. For more information, see Query comments.
- Delete comments.
 After retrieving all keys of the comments, you can use the DeleteComments method.
Consider the code sample below:
 
 
You may need to programmatically delete all comments for a specific content item by the item's ID. In the following example, you delete all comments for a specific News item by its ID. Follow the steps below:
    - Get an instance of the comments service.
 Use the GetCommentsService method of the SystemManager.
- To find all comments related to the specific News item, you use the ID of the News item and create a new thread key. 
 Add the thread key in the CommentFilter and use the filter the get all comments. For more information, see Query comments.
Consider the code sample below: