How to Get Entity Counters


  • When a document is loaded to the session,
    the loaded entity will contain various metadata information such as ID, current change-vector, and more.

  • If the document has Counters, the document metadata will also contain its counter names.
    The counter names are available for each entity using the GetCountersFor() method from the Advanced session operations.

  • In this page:


Get entity counters

// Load a document
var employee = session.Load<Employee>("employees/1-A");

// Get counter names from the loaded entity
List<string> counterNames = session.Advanced.GetCountersFor(employee);

Syntax

List<string> GetCountersFor<T>(T instance);
Parameters
instance T Instance of an entity for which counter names will be returned.
Return Value
List<string> Returns the counter names for the specified entity, or null if the entity has no counters.
An exception is thrown if the instance is not tracked by the session.