Delete blogs

This topic explains how to delete blogs. The examples below show you how to delete all of the available blogs or how to delete only a specific blog by its ID.

Delete a single blog

When deleting a specific blog by its ID, you must perform the following:

  1. Get the blog.
    First, get an instance of the blog that corresponds to the specified ID. 
  2. Delete the blog.
    Mark the blog to be deleted and save the changes.

The following code deletes a blog by its ID:

Native API

First, you get an instance of the BlogsManager class. Then, you get the blog with the specified ID. To mark the blog to be deleted, you call the DeleteBlog method of the manager with the instance of the blog as an argument. Finally, you save the changes.

Fluent API

First, you get the singular facade of the blog with the specified ID. To mark the blog to be deleted, you call the Delete method of the facade. Finally, you call SaveChanges.

Delete all blogs

When deleting all blogs, you must perform the following:

  1. Get all blogs.
    Get instances of the available blogs.
  2. Delete each blog in the collection.
    Iterate through the collection and delete each blog.

The following code deletes all blogs.

Native API

First, you get an instance of the BlogsManager class. Then, you get all of the available blogs. You iterate through the collection and mark each blog to be deleted. Finally, you save the changes.

Fluent API

First, you get the plural blogs facade. To mark each blog to be deleted, you call the Delete method of the facade. Finally, you save the changes.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?