Beispiel #1
0
        private void GetEventProviderInformation(SqlDataReader dataReader)
        {
            // event provider global identity
            _eventProviderIdentity = new EventProviderIdentity(dataReader.GetGuid(0));

            // read snapshot
            _sqlSnapshot = GetSnapshot(dataReader);
        }
        public ProjectionInstance(ProjectionType projectionType, EventProviderIdentity eventProviderIdentity, ProjectionPosition position)
        {
            Contract.Requires(projectionType != null);
            Contract.Requires(eventProviderIdentity != null);
            Contract.Requires(position != null);

            ProjectionType        = projectionType;
            EventProviderIdentity = eventProviderIdentity;
            Position = position;
        }
        public GetPositionCommand(ITypeFactory typeFactory,
                                  ProjectionType projectionType,
                                  EventProviderIdentity eventProviderIdentity)
        {
            Contract.Requires(typeFactory != null);
            Contract.Requires(projectionType != null);
            Contract.Requires(eventProviderIdentity != null);

            _projectionType        = projectionType;
            _eventProviderIdentity = eventProviderIdentity;

            _command = CreateSqlCommand(typeFactory, projectionType, eventProviderIdentity);
        }
Beispiel #4
0
        public async Task <ProjectionInstance> GetPositionAsync <TProjection>(EventProviderIdentity eventProviderIdentity) where TProjection : IProjection
        {
            // establish command
            var command = new GetPositionCommand(_typeFactory, new ProjectionType(typeof(TProjection)), eventProviderIdentity);

            // create connection
            using (var conn = new SqlConnection(_connectionString))
            {
                // connection needs to be open before executing
                conn.Open();

                // execute
                return(await command.ExecuteAsync(conn));
            }
        }
        private SqlCommand CreateSqlCommand(ITypeFactory typeFactory, ProjectionType projectionType, EventProviderIdentity eventProviderIdentity)
        {
            var sqlCommand = new SqlCommand("[dbo].[GetProjectionPosition]");

            sqlCommand.CommandType = CommandType.StoredProcedure;

            // set parameters
            sqlCommand.Parameters.Add("@projectionId", SqlDbType.UniqueIdentifier).Value    = typeFactory.GetHash(projectionType.Type);
            sqlCommand.Parameters.Add("@eventProviderId", SqlDbType.UniqueIdentifier).Value = eventProviderIdentity.Value;

            return(sqlCommand);
        }