Error CS0121: The call is ambiguous between the following methods or properties: 'Watcher<T>.Start(EventType, Expression<Func<ChangeStreamDocument<T>, bool>>, int, bool, bool, CancellationToken)' and 'Watcher<T>.Start(EventType, Func<FilterDefinitionBuilder<ChangeStreamDocument<T>>, FilterDefinition<ChangeStreamDocument<T>>>, int, bool, bool, CancellationToken)'
I can fix the build error by simply removing the "filter" option:
When I setup the watcher per the instructions:
watcher.Start( eventTypes: EventType.Created | EventType.Updated | EventType.Deleted, filter: null, batchSize: 25, onlyGetIDs: false, autoResume: true, cancellation: default);
I get the following 'ambiguous' build error:
Error CS0121: The call is ambiguous between the following methods or properties: 'Watcher<T>.Start(EventType, Expression<Func<ChangeStreamDocument<T>, bool>>, int, bool, bool, CancellationToken)' and 'Watcher<T>.Start(EventType, Func<FilterDefinitionBuilder<ChangeStreamDocument<T>>, FilterDefinition<ChangeStreamDocument<T>>>, int, bool, bool, CancellationToken)'
I can fix the build error by simply removing the "filter" option:
watcher.Start( eventTypes: EventType.Created | EventType.Updated | EventType.Deleted, batchSize: 25, onlyGetIDs: false, autoResume: true, cancellation: default);
However, when I execute the console app, it falls right through the watcher and nothing happens. Here's the full code:
await DB.InitAsync("Google", MongoClientSettings.FromConnectionString( "connection_string_redacted"));
var watcher = DB.Watcher("employee-watcher");
watcher.Start( eventTypes: EventType.Created | EventType.Updated | EventType.Deleted, batchSize: 25, onlyGetIDs: false, autoResume: true, cancellation: default);
watcher.OnChanges += employees => { foreach (var employee in employees) { Console.WriteLine("received: " + employee.Name); } };
watcher.OnError += exception => { Console.WriteLine("error: " + exception.Message); if (watcher.CanRestart) { watcher.ReStart(); Console.WriteLine("Watching restarted!"); } };
watcher.OnStop += () => { Console.WriteLine("Watching stopped!"); if (watcher.CanRestart) { watcher.ReStart(); Console.WriteLine("Watching restarted!"); } else { Console.WriteLine("This watcher is dead!"); } };