You are currently browsing legacy 3.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

Session: How to clear a session?

To clear session state, that is to stop tracking entities and remove all pending commands, etc. Clear method is used from Advanced session operations.

Syntax

void Clear();

Example

session.Store(new Employee
				  {
					  FirstName = "John",
					  LastName = "Doe"
				  });

session.Advanced.Clear();

session.SaveChanges(); // nothing will happen