Listeners: What are delete listeners and how to work with them?
IDocumentDeleteListener interface which needs to be implemented if a user wants to add a custom logic or an action when a delete operation is executed.
The interface contains only one method that is invoked before the delete request is sent to the server:
public interface IDocumentDeleteListener
/// Invoked before the delete request is sent to the server.
/// <param name="key">The key.</param>
/// <param name="entityInstance">The entity instance.</param>
/// <param name="metadata">The metadata.</param>
void BeforeDelete(string key, object entityInstance, RavenJObject metadata);
To prevent anyone from deleting documents we can create PreventDeleteListener with can be implemented as follows:
public class PreventDeleteListener : IDocumentDeleteListener
public void BeforeDelete(string key, object entityInstance, RavenJObject metadata)
throw new NotSupportedException();