I'm working on trying to retrieve changed items in a sharepoint document list.
It's simple enough to "identify" the id's of the changed items.
IList documentsList = await context.Web.Lists.GetByTitleAsync("Documents");
IList<IChange> changes = await documentsList.GetChangesAsync(new ChangeQueryOptions(false, false)
{
Item = true,
Add = true,
Update = true,
DeleteObject = true,
Rename = true,
Move = true,
RecursiveAll = true,
});
however the next step is to iterate through the list and load each item one by one using their ItemId.
List<IChangeItem> changeItems = changes.Where(c => c is IChangeItem).Cast<IChangeItem>().ToList();
foreach (var change in changeItems)
{
IListItem item = await documentsList.Items.GetByIdAsync(change.ItemId, p => p.Title, p => p.File, p => p.Folder, p => p.FileSystemObjectType);
}
Which results in a separate round trip to the sharepoint server and seems inefficient to me so I want to know how to bulk load or batch load based on a list of id's.
Neither the working with lists documentation https://pnp.github.io/pnpcore/using-the-sdk/listitems-intro.html nor the Using Batching documentation https://pnp.github.io/pnpcore/using-the-sdk/basics-batching.html seem to cover bulk retrieval of items by Id.
Batching examples seem to involve querying by a single property.
I'm looking for something that fits the functional intent of this...
var changeItemIds = changes.Where(c => c is IChangeItem).Cast<IChangeItem>().Select(c => c.ItemId).ToList();
var result = await documentsList.Items.GetByIdAsync
.Where(i => changeItemIds.Contains(i.Id))
.QueryProperties(p => p.Title, p => p.File, p => p.Folder, p => p.FileSystemObjectType)
.ToListAsync();
however I appreciate that things are different in sharepoint and I expect that it won't look much like that at all.
Thanks in advance.