コード例 #1
0
        public async Task InstallProjectionFor <TProjection>() where TProjection : IEventStoreProjection
        {
            var matchingProjections = _projections.OfType <TProjection>().ToList();

            var projectionBuilder = new ProjectionBuilder();
            var projectionManager = _eventStoreConnectionString.CreateProjectionsManager();
            var credentials       = _eventStoreConnectionString.GetUserCredentials();

            foreach (var projection in matchingProjections)
            {
                var name  = $"project-to-{projection.ProjectionName}";
                var query = projectionBuilder.BuildStreamProjection(projection.GetInterestingStreams(), projection.ProjectionName);

                await projectionManager.CreateOrUpdateContinuousQueryAsync(name, query, credentials).ConfigureAwait(false);
            }
        }
コード例 #2
0
        public async Task InstallProjectionFor <TProcessManager>() where TProcessManager : IManageProcess
        {
            var matchingProcessManagers = _processManagers.OfType <TProcessManager>().ToList();

            var projectionBuilder = new ProjectionBuilder();
            var projectionManager = _eventStoreConnectionString.CreateProjectionsManager();
            var credentials       = _eventStoreConnectionString.GetUserCredentials();

            foreach (var processManager in matchingProcessManagers)
            {
                var name  = $"project-to-{processManager.ProcessName}";
                var query = projectionBuilder.BuildStreamProjection(processManager.GetStreamsToProcess(),
                                                                    processManager.ProcessName,
                                                                    processManager.GetEventMappings().Select(x => new ProjectionBuilder.EventMap(x.Key.Name, x.Value)));

                await projectionManager.CreateOrUpdateContinuousQueryAsync(name, query, credentials).ConfigureAwait(false);
            }
        }