Skip to content

How do I use list.GetChangesBatchAsync() to Get ALL Changes for a Given Change Query? #1228

Answered by adamfisher
adamfisher asked this question in Q&A
Discussion options

You must be logged in to vote

I ended up doing this since I couldn't figure out how to use the batch version:

public static async Task<List<IChange>> GetAllChangesAsync(this IList list, ChangeQueryOptions queryOptions)
{
	IList<IChange> changes = await list.GetChangesAsync(queryOptions);
	List<IChange> results = new(changes);

	while (changes.Count > 0)
	{
		var lastChangeToken = changes.Last().ChangeToken;
		queryOptions.ChangeTokenStart = lastChangeToken;
		changes = await list.GetChangesAsync(queryOptions);
		results.AddRange(changes);
	}

	return results;
}

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@adamfisher
Comment options

Comment options

You must be logged in to vote
1 reply
@jansenbe
Comment options

Answer selected by adamfisher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants