Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SqlEventStoreConfiguration"/> class.
        /// </summary>
        /// <param name="entityName">The name of the entity the event store is for.</param>
        /// <param name="providerFactory">The <see cref="DbProviderFactory">provider factory</see> for underlying database operations.</param>
        /// <param name="connectionString">The database connection string.</param>
        /// <param name="tableName">The event store table name.</param>
        /// <param name="snapshots">The associated <see cref="SqlSnapshotConfiguration">snapshot configuration</see>.</param>
        /// <param name="messageTypeResolver">The <see cref="IMessageTypeResolver">message type resolver</see> used to deserialize messages.</param>
        /// <param name="serializerFactory">The <see cref="ISqlMessageSerializerFactory">factory</see> used to create new message serializers.</param>
        public SqlEventStoreConfiguration(
            string entityName,
            DbProviderFactory providerFactory,
            string connectionString,
            SqlIdentifier tableName,
            SqlSnapshotConfiguration snapshots,
            IMessageTypeResolver messageTypeResolver,
            ISqlMessageSerializerFactory serializerFactory)
        {
            Arg.NotNullOrEmpty(entityName, nameof(entityName));
            Arg.NotNull(providerFactory, nameof(providerFactory));
            Arg.NotNullOrEmpty(connectionString, nameof(connectionString));
            Arg.NotNull(snapshots, nameof(snapshots));
            Arg.NotNull(messageTypeResolver, nameof(messageTypeResolver));
            Arg.NotNull(serializerFactory, nameof(serializerFactory));

            EntityName             = entityName;
            ProviderFactory        = providerFactory;
            this.connectionString  = connectionString;
            this.serializerFactory = serializerFactory;
            TableName           = tableName;
            Snapshots           = snapshots;
            MessageTypeResolver = messageTypeResolver;
            EventSerializer     = serializerFactory.NewSerializer <IEvent>();
            Sql = new SqlBuilder(this, snapshots);
        }
Example #2
0
        internal SqlBuilder(SqlEventStoreConfiguration eventStore, SqlSnapshotConfiguration snapshots)
        {
            Contract.Requires(eventStore != null);
            Contract.Requires(snapshots != null);

            EventStore = new EventStoreSqlBuilder(eventStore.TableName);
            Snapshots  = new SnapshotSqlBuilder(snapshots.TableName);
        }
        /// <summary>
        /// Enables aggregate snapshots for the event store configuration.
        /// </summary>
        /// <param name="tableName">The configured snapshot store table name. The default value is "Snapshot".</param>
        /// <param name="schemaName">The configured snapshot store schema name. The default value is "Snapshots".</param>
        /// <returns>The original <see cref="SqlEventStoreConfigurationBuilder">builder</see>.</returns>
        public virtual SqlEventStoreConfigurationBuilder SupportsSnapshots(string tableName = "Snapshot", string schemaName = "Snapshots")
        {
            Arg.NotNullOrEmpty(tableName, nameof(tableName));
            Arg.NotNullOrEmpty(schemaName, nameof(schemaName));
            Contract.Ensures(Contract.Result <SqlEventStoreConfigurationBuilder>() != null);

            Snapshots = new SqlSnapshotConfiguration(new SqlIdentifier(schemaName, tableName), supported: true);
            return(this);
        }