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

Changes API: How to subscribe to bulk insert operation changes?

ForBulkInsert method can be used to acquire notifications for bulk insert operations.

Syntax

IObservableWithTask<BulkInsertChangeNotification>
	ForBulkInsert(Guid operationId);

Parameters
operationId Guid Id of bulk insert operation, generated when bulk insert operation is created.
ReturnValue
IObservableWithTask<BulkInsertChangeNotification> Observable that allows to add subscriptions to notifications for bulk insert operation with given id.

Example

using (BulkInsertOperation bulkInsert = store.BulkInsert())
{
	IDisposable subscribtion = store
		.Changes()
		.ForBulkInsert(bulkInsert.OperationId)
		.Subscribe(change =>
		{
			switch (change.Type)
			{
				case DocumentChangeTypes.BulkInsertStarted:
					// do something
					break;
				case DocumentChangeTypes.BulkInsertEnded:
					// do something
					break;
				case DocumentChangeTypes.BulkInsertError:
					// do something
					break;
			}
		});

	try
	{
		for (int i = 0; i < 1000 * 1000; i++)
		{
			bulkInsert.Store(new Employee
			{
				FirstName = "FirstName #" + i,
				LastName = "LastName #" + i
			});
		}
	}
	finally
	{
		if (subscribtion != null)
			subscribtion.Dispose();
	}
}

Remarks

Information

To get more method overloads, especially the ones supporting delegates, please add Reactive Extensions package to your project.