Write an "if" condition.
if(eventInstance.Id != 4703 & eventInstance.Id != 5156)
{
var logStore = new LogStore()
{
EventId = eventInstance.Id,
EventRecord = (int?)eventInstance.RecordId,
TimeStamp = (DateTime?)eventInstance.TimeCreated,
Description = eventInstance.FormatDescription(),
TaskCategory = eventInstance.TaskDisplayName,
Level = eventInstance.LevelDisplayName,
};
await _applicationDbContext.AddAsync(logStore);
await _applicationDbContext.SaveChangesAsync(token);
}
Maybe you can filter with the unknown eventsQuery? Maybe use LINQ's Any() or Where()?