Language
Java Node.JS
Article For
3.0 3.5 4.0 4.1 4.2 5.0 5.1

Session: How to Clear a Session

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

Syntax

void Clear();

Example

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

session.Advanced.Clear();

session.SaveChanges(); // nothing will happen