You are currently browsing legacy 4.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Attachments: Deleting Attachments

Delete from session.advanced().attachments() is used to remove an attachment from a document.

Syntax

void delete(String documentId, String name);

void delete(Object entity, String name);

Example

try (IDocumentSession session = store.openSession()) {
    Album album = session.load(Album.class, "albums/1");
    session.advanced().attachments().delete(album, "001.jpg");
    session.advanced().attachments().delete("albums/1", "002.jpg");

    session.saveChanges();
}