I am trying to get the count of the attachments for a document where I apply a criteria to the count.
In pseudo-code
var counts = document.getMetaData("@attachments").where(c=>c.Name.Contains(filter))
I can't use session.Advanced.GetMetaDataFor(document.Id)["@attachments"].
I have tried this code (straight out of the documentation), but cannot work out how to get and filter on the 'Name' property of the 'attachment'
Basically I want to cast 'attachment' to something I can manipulate
var command = new GetDocumentsCommand(contract.Id, null, metadataOnly: true);
_session.Advanced.RequestExecutor.Execute(command,_session.Advanced.Context);
var result = (BlittableJsonReaderObject)command.Result.Results[0];
var documentMetaData = (BlittableJsonReaderObject)result["@metadata"];
if (documentMetaData["@attachments"] is BlittableJsonReaderArray attachments)
{
foreach(var attachment in attachments)
{
var propertyNames= attachment.GetType().GetProperties().Select(x => x.Name).ToList();
Console.WriteLine(
propertyNames );
}
}