Skip to main content

Get Revisions Operation

Get all revisions

// Define the get revisions operation, pass the document id
var getRevisionsOp = new GetRevisionsOperation<Company>("Companies/1-A");

// Execute the operation by passing it to Operations.Send
RevisionsResult<Company> revisions = documentStore.Operations.Send(getRevisionsOp);

// The revisions info:
List<Company> allRevisions = revisions.Results; // All the revisions
int revisionsCount = revisions.TotalResults; // Total number of revisions

Paging results

  • Get and process revisions, one page at a time:
var start = 0;
var pageSize = 100;

while (true)
{
// Execute the get revisions operation
// Pass the document id, start & page size to get
RevisionsResult<Company> revisions = documentStore.Operations.Send(
new GetRevisionsOperation<Company>("Companies/1-A", start, pageSize));

{
// Process the retrieved revisions here
}

if (revisions.Results.Count < pageSize)
break; // No more revisions to retrieve

// Increment 'start' by page-size, to get the "next page" in next iteration
start += pageSize;
}
  • The document ID, start & page size can be wrapped in a Parameter object:
var parameters = new GetRevisionsOperation<Company>.Parameters
{
Id = "Companies/1-A",
Start = 0,
PageSize = 100
};

RevisionsResult<Company> revisions = documentStore.Operations.Send(
new GetRevisionsOperation<Company>(parameters));

Syntax

Available overloads:

// Get all revisions for the specified document:
public GetRevisionsOperation(string id);

// Page revisions:
public GetRevisionsOperation(string id, int start, int pageSize);
public GetRevisionsOperation(Parameters parameters)
ParameterTypeDescription
idstringDocument ID for which to get revisions
startintRevision number to start from
pageSizeintNumber of revisions to get
parametersParametersAn object that wraps Id, Start, and PageSize (see below)
public class Parameters
{
public string Id { get; set; } // Document ID for which to get revisions
public int? Start { get; set; } // Revision number to start from
public int? PageSize { get; set; } // Number of revisions to get
}
Return value of store.Operations.Send(getRevisionsOp)
RevisionsResult<T>Object with revisions results
public class RevisionsResult<T>
{
public List<T> Results { get; set; } // The retrieved revisions
public int TotalResults { get; set; } // Total number of revisions that exist for the document
}