Session: Saving changes

Pending session operations e.g. Store, Delete and many others will not be send to server till SaveChanges is called.

Syntax

void SaveChanges();

Example

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

session.SaveChanges();

Waiting for indexes

You can ask the server to wait until the indexes are caught up with this particular write after save changes. You can also set a timeout and whatever to throw or not. You can specify indexes that you want to wait for. If you don't specify anything, RavenDB will automatically select just the indexes that are impacted by this write.

session.Advanced.WaitForIndexesAfterSaveChanges(timeout: TimeSpan.FromSeconds(30));
session.Store(new Employee
{
    FirstName = "John",
    LastName = "Doe"
});

session.SaveChanges();