Delete Counter

  • Use the CountersFor.Delete method to remove a specific Counter from a document.

  • All the document's Counters are deleted when the document itself is deleted.

  • For all other CountersFor methods see this Overview.

  • In this page:

Delete usage


  • Open a session.
  • Create an instance of CountersFor.
  • Call CountersFor.Delete.
  • Call session.SaveChanges for the changes to take effect.


  • A Counter you deleted will be removed only after the execution of SaveChanges().
  • Delete will not generate an error if the Counter doesn't exist.
  • Deleting a document deletes all its Counters as well.


// 1. Open a session
using (var session = docStore.OpenSession())
    // 2. pass CountersFor's constructor a document ID  
    var documentCounters = session.CountersFor("products/1-C");

    // 3. Delete the "ProductLikes" Counter

    // 4. The 'Delete' is executed upon calling SaveChanges


void Delete(string counterName);
Parameter Type Description
counterName string Counter's name