Exemple #1
0
        public static SqlPersistenceWireup UsingSqlPersistence(
            this Wireup wireup, string masterConnectionName, string replicaConnectionName)
        {
            var factory = new ConfigurationConnectionFactory(masterConnectionName, replicaConnectionName, 1);

            return(wireup.UsingSqlPersistence(factory));
        }
        static void Main(string[] args)
        {
            ConnectionString = ConfigurationManager.AppSettings["connectionString"];
            var config = new ConfigurationConnectionFactory("NEventStoreProc", "system.data.sqlclient", ConnectionString);

            InvoiceProjectionSetup.CreateSchemaIfNotExists();

            StoreEvents = Wireup.Init()
                          .UsingSqlPersistence((config))
                          .WithDialect(new MsSqlDialect())
                          .EnlistInAmbientTransaction()
                          .InitializeStorageEngine()
                          .UsingJsonSerialization()

                          .Build();

            _invoicesProjection = new InvoicesProjection();
            _invoicesProjection.Init();

            var baseAddress = "http://localhost:9000/";

            // Start OWIN host
            using (WebApp.Start(baseAddress, Configuration))
            {
                Console.WriteLine("Host started");
                Console.ReadLine();
            }
            _invoicesProjection.Dispose();
        }
        /// <summary>
        /// Usings the firebird connection string.
        /// </summary>
        /// <param name="wireup">The wireup.</param>
        /// <param name="name">The name.</param>
        /// <param name="connectionString">The connection string.</param>
        /// <param name="providerName">Name of the provider.</param>
        /// <param name="initialize">if set to <c>true</c> [initialize].</param>
        /// <returns>The FirebirdSqlPersistenceWireup instance properly configured.</returns>
        public static FirebirdSqlPersistenceWireup UsingFirebirdConnectionString(this Wireup wireup, string name, string connectionString, string providerName, bool initialize = false)
        {
            var connectionFactory = new ConfigurationConnectionFactory(name, providerName, connectionString);
            var persistence = new FirebirdSqlPersistenceWireup(wireup, connectionFactory);
            if (initialize)
            {
                persistence.InitializeStorageEngine();
            }

            return persistence;
        }
Exemple #4
0
        public static IStoreEvents CreateSqlConnection()
        {
            var config = new ConfigurationConnectionFactory(
                "NEventStorePoc", "system.data.sqlclient", ConnectionString);

            return(Wireup.Init()
                   .UsingSqlPersistence(config)
                   .WithDialect(new MsSqlDialect())
                   .InitializeStorageEngine()
                   .Build());
        }
        /// <summary>
        /// Usings the firebird connection string.
        /// </summary>
        /// <param name="wireup">The wireup.</param>
        /// <param name="name">The name.</param>
        /// <param name="connectionString">The connection string.</param>
        /// <param name="providerName">Name of the provider.</param>
        /// <param name="initialize">if set to <c>true</c> [initialize].</param>
        /// <returns>The FirebirdSqlPersistenceWireup instance properly configured.</returns>
        public static FirebirdSqlPersistenceWireup UsingFirebirdConnectionString(this Wireup wireup, string name, string connectionString, string providerName, bool initialize = false)
        {
            var connectionFactory = new ConfigurationConnectionFactory(name, providerName, connectionString);
            var persistence       = new FirebirdSqlPersistenceWireup(wireup, connectionFactory);

            if (initialize)
            {
                persistence.InitializeStorageEngine();
            }

            return(persistence);
        }
        /// <summary>
        /// Extension method which allows using the FirebirdSqlPersistenceEngine instead of SqlPersistenceEngine.
        /// This Engine sends statements in different commands.
        /// </summary>
        /// <param name="wireup">The wireup.</param>
        /// <param name="connectionName">Name of the connection.</param>
        /// <param name="initialize">if set to <c>true</c> [initialize].</param>
        /// <returns>FirebirdSqlPersistenceWireup.</returns>
        public static FirebirdSqlPersistenceWireup UsingFirebirdPersistence(this Wireup wireup, string connectionName, bool initialize = false)
        {
            var factory = new ConfigurationConnectionFactory(connectionName);
            FirebirdSqlPersistenceWireup wire = new FirebirdSqlPersistenceWireup(wireup, factory);

            if (initialize)
            {
                wire.InitializeStorageEngine();
            }

            return(wire);
        }
        /// <summary>
        /// Extension method which allows using the FirebirdSqlPersistenceEngine instead of SqlPersistenceEngine.
        /// This Engine sends statements in different commands.
        /// </summary>
        /// <param name="wireup">The wireup.</param>
        /// <param name="connectionName">Name of the connection.</param>
        /// <param name="initialize">if set to <c>true</c> [initialize].</param>
        /// <returns>FirebirdSqlPersistenceWireup.</returns>
        public static FirebirdSqlPersistenceWireup UsingFirebirdPersistence(this Wireup wireup, string connectionName, bool initialize = false)
        {
            var factory = new ConfigurationConnectionFactory(connectionName);
            FirebirdSqlPersistenceWireup wire = new FirebirdSqlPersistenceWireup(wireup, factory);

            if (initialize)
            {
                wire.InitializeStorageEngine();
            }

            return wire;
        }
Exemple #8
0
        /// <summary>
        /// Wireup of the sql server repository
        /// </summary>
        /// <param name="wireup"></param>
        /// <returns></returns>
        private Wireup WireupSqlServerRepository(Wireup wireup)
        {
            // we need to make sure the database exists and also pull the db name out of the connection string
            var connectionString         = new ConfigurationConnectionFactory("EventStore_SqlServer").Settings.ConnectionString;
            var databaseNameRegex        = @"(Initial Catalog=.*$)|(Initial Catalog=.*[;])";
            var connectionStringModified = Regex.Replace(connectionString, databaseNameRegex, "Initial Catalog=master");
            var databaseName             = Regex.Match(connectionString, databaseNameRegex).Captures[0].Value.Replace("Initial Catalog=", string.Empty);

            bool exists = false;

            using (var sqlConnection = new SqlConnection(connectionStringModified))
            {
                var sqlCreateDBQuery = string.Format("SELECT database_id FROM sys.databases WHERE Name = '{0}'", databaseName);
                using (var sqlCmd = new SqlCommand(sqlCreateDBQuery, sqlConnection))
                {
                    sqlConnection.Open();
                    var dbId = sqlCmd.ExecuteScalar();
                    exists = (dbId != null) && (Convert.ToInt32(dbId) > 0);
                    sqlConnection.Close();
                }
            }

            if (!exists)
            {
                using (var sqlConnection = new SqlConnection(connectionStringModified))
                {
                    var sqlCreateDBQuery = string.Format("CREATE DATABASE {0}", databaseName);
                    using (var sqlCmd = new SqlCommand(sqlCreateDBQuery, sqlConnection))
                    {
                        sqlConnection.Open();
                        sqlCmd.ExecuteScalar();
                        sqlConnection.Close();
                    }
                }
            }

            return(wireup
                   .UsingSqlPersistence("EventStore_SqlServer")
                   .WithDialect(new MsSqlDialect())
                   .InitializeStorageEngine()
                   .UsingBsonSerialization());
        }
Exemple #9
0
        public static SqlPersistenceWireup UsingSqlPersistence(this Wireup wireup, string connectionName)
        {
            var factory = new ConfigurationConnectionFactory(connectionName);

            return(wireup.UsingSqlPersistence(factory));
        }
 public static SqlPersistenceWireup UsingSqlPersistence(this Wireup wireup, string connectionName)
 {
     var factory = new ConfigurationConnectionFactory(connectionName);
     return wireup.UsingSqlPersistence(factory);
 }
        public static SqlPersistenceWireup UsingSqlPersistence(
			this Wireup wireup, string masterConnectionName, string replicaConnectionName)
        {
            var factory = new ConfigurationConnectionFactory(masterConnectionName, replicaConnectionName, 1);
            return wireup.UsingSqlPersistence(factory);
        }