I have this bit of code to check if the projection exists and if it does not add it, however I get “One or more errors occurred…” message when trying to ListAllAsync.
private static IPEndPoint CreateIpEndPoint(string host, int port)
{
var address = IPAddress.Parse(host);
return new IPEndPoint(address, port);
}
private async Task EnsureProjectionExists(IPEndPoint endPoint)
{
var pm = new ProjectionsManager(this.eventStoreLogger, endPoint, TimeSpan.FromSeconds(10));
var projectionName = "allNonSystemEvents";
var projections = await pm.ListAllAsync(EventStoreCredentials.Default);
var allNonSystemEventsProjection = projections.SingleOrDefault(x => x.Name == projectionName);
if (allNonSystemEventsProjection == null)
{
var query = @"
fromAll().
when({
$any : function(s,e) {
if (e.eventType && !e.eventType.startsWith('$'))
linkTo('allNonSystemEvents', e);
}});";
await pm.CreateContinuousAsync(projectionName, query, trackEmittedStreams: true);
}
await pm.EnableAsync(projectionName);
}
``