예제 #1
0
        /// <summary>
        /// Creates the SQL configuration.
        /// </summary>
        /// <typeparam name="TThisConfiguration">The type of the configuration.</typeparam>
        /// <typeparam name="TConnectionString">The type of connection string.</typeparam>
        /// <param name="provider">The SQL configuration provider.</param>
        /// <returns>Created SQL configuration</returns>
        private IPersistenceConfigurer CreateSqlConfiguration <TThisConfiguration, TConnectionString>(PersistenceConfiguration <TThisConfiguration, TConnectionString> provider)
            where TThisConfiguration : PersistenceConfiguration <TThisConfiguration, TConnectionString>
            where TConnectionString : ConnectionStringBuilder, new()
        {
            PersistenceConfiguration <TThisConfiguration, TConnectionString> sqlConfiguration;

            if (!string.IsNullOrEmpty(configuration.Database.ConnectionString))
            {
                sqlConfiguration = provider.ConnectionString(configuration.Database.ConnectionString);
            }
            else if (!string.IsNullOrEmpty(configuration.Database.ConnectionStringName))
            {
                sqlConfiguration = provider.ConnectionString(f => f.FromConnectionStringWithKey(configuration.Database.ConnectionStringName));
            }
            else
            {
                sqlConfiguration = null;
            }

            if (sqlConfiguration != null)
            {
                if (!string.IsNullOrEmpty(configuration.Database.SchemaName))
                {
                    sqlConfiguration.DefaultSchema(configuration.Database.SchemaName);
                }
            }

            return(sqlConfiguration);
        }
예제 #2
0
        private static void ConfigurarStringConexao <TThisConfiguration, TConnectionString>(
            this FluentConfiguration configFluente,
            PersistenceConfiguration <TThisConfiguration, TConnectionString> persistenceConfiguration,
            bool showSql)
            where TThisConfiguration : PersistenceConfiguration <TThisConfiguration, TConnectionString>
            where TConnectionString : ConnectionStringBuilder, new()
        {
            const string connectionStringKey = "ExemploConexao";

            if (showSql)
            {
                persistenceConfiguration.ShowSql();
            }
            persistenceConfiguration.ConnectionString(c => c.FromConnectionStringWithKey(connectionStringKey));
            configFluente.Database(persistenceConfiguration);
        }