Inheritance: Shaolinq.Persistence.SqlDatabaseContextInfo
コード例 #1
0
        public static PostgresSqlDatabaseContext Create(PostgresSqlDatabaseContextInfo contextInfo, DataAccessModel model)
        {
            var constraintDefaults       = model.Configuration.ConstraintDefaults;
            var sqlDialect               = PostgresSqlDialect.Default;
            var sqlDataTypeProvider      = new PostgresSqlDataTypeProvider(constraintDefaults, contextInfo.NativeUuids, contextInfo.NativeEnums);
            var sqlQueryFormatterManager = new DefaultSqlQueryFormatterManager(sqlDialect, sqlDataTypeProvider, (options, sqlDataTypeProviderArg, sqlDialectArg) => new PostgresSqlQueryFormatter(options, sqlDataTypeProviderArg, sqlDialectArg, contextInfo.SchemaName, true));

            return(new PostgresSqlDatabaseContext(model, sqlDialect, sqlDataTypeProvider, sqlQueryFormatterManager, contextInfo));
        }
コード例 #2
0
		public static PostgresSqlDatabaseContext Create(PostgresSqlDatabaseContextInfo contextInfo, DataAccessModel model)
		{
			var constraintDefaults = model.Configuration.ConstraintDefaultsConfiguration;
			var sqlDialect = new PostgresSqlDialect();
			var sqlDataTypeProvider = new PostgresSqlDataTypeProvider(model.TypeDescriptorProvider, constraintDefaults, contextInfo.NativeUuids, contextInfo.NativeEnums);
			var sqlQueryFormatterManager = new DefaultSqlQueryFormatterManager(sqlDialect, sqlDataTypeProvider, (options, sqlDataTypeProviderArg, sqlDialectArg) => new PostgresSqlQueryFormatter(options, sqlDataTypeProviderArg, sqlDialectArg, contextInfo.SchemaName, true));

			return new PostgresSqlDatabaseContext(model, sqlDialect, sqlDataTypeProvider, sqlQueryFormatterManager, contextInfo);
		}
コード例 #3
0
		public static DataAccessModelConfiguration Create(PostgresSqlDatabaseContextInfo contextInfo)
		{
			return new DataAccessModelConfiguration
			{
				SqlDatabaseContextInfos = new SqlDatabaseContextInfo[]
				{
					contextInfo
				}
			};
		}
コード例 #4
0
 public static DataAccessModelConfiguration Create(PostgresSqlDatabaseContextInfo contextInfo)
 {
     return(new DataAccessModelConfiguration
     {
         SqlDatabaseContextInfos = new SqlDatabaseContextInfo[]
         {
             contextInfo
         }
     });
 }
コード例 #5
0
        public static PostgresSqlDatabaseContext Create(PostgresSqlDatabaseContextInfo contextInfo, DataAccessModel model)
        {
            var constraintDefaults       = model.Configuration.ConstraintDefaultsConfiguration;
            var sqlDialect               = new PostgresSqlDialect();
            var sqlDataTypeProvider      = CreateSqlDataTypeProvider(model, contextInfo, () => new PostgresSqlDataTypeProvider(model.TypeDescriptorProvider, constraintDefaults, contextInfo.NativeUuids, contextInfo.NativeEnums));
            var typeDescriptorProvider   = model.TypeDescriptorProvider;
            var sqlQueryFormatterManager = new DefaultSqlQueryFormatterManager(sqlDialect, model.Configuration.NamingTransforms, (options, connection) => new PostgresSqlQueryFormatter(options, sqlDialect, sqlDataTypeProvider, typeDescriptorProvider, contextInfo.SchemaName, true));

            return(new PostgresSqlDatabaseContext(model, sqlDialect, sqlDataTypeProvider, sqlQueryFormatterManager, contextInfo));
        }
コード例 #6
0
        protected PostgresSqlDatabaseContext(DataAccessModel model, SqlDialect sqlDialect, SqlDataTypeProvider sqlDataTypeProvider, SqlQueryFormatterManager sqlQueryFormatterManager, PostgresSqlDatabaseContextInfo contextInfo)
            : base(model, sqlDialect, sqlDataTypeProvider, sqlQueryFormatterManager, contextInfo.DatabaseName, contextInfo)
        {
            this.Host = contextInfo.ServerName;
            this.UserId = contextInfo.UserId;
            this.Password = contextInfo.Password;
            this.Port = contextInfo.Port;
            this.CommandTimeout = TimeSpan.FromSeconds(contextInfo.CommandTimeout);

            this.ConnectionString = String.Format("Host={0};User Id={1};Password={2};Database={3};Port={4};Pooling={5};MinPoolSize={6};MaxPoolSize={7};Enlist=false;Timeout={8};CommandTimeout={9}", contextInfo.ServerName, contextInfo.UserId, contextInfo.Password, contextInfo.DatabaseName, contextInfo.Port, contextInfo.Pooling, contextInfo.MinPoolSize, contextInfo.MaxPoolSize, contextInfo.ConnectionTimeout, contextInfo.CommandTimeout);
            this.ServerConnectionString = Regex.Replace(this.ConnectionString, @"Database\s*\=[^;]+[;$]", "Database=postgres;");

            this.SchemaManager = new PostgresSharedSqlDatabaseSchemaManager(this);
        }
コード例 #7
0
		protected PostgresSqlDatabaseContext(DataAccessModel model, SqlDialect sqlDialect, SqlDataTypeProvider sqlDataTypeProvider, SqlQueryFormatterManager sqlQueryFormatterManager, PostgresSqlDatabaseContextInfo contextInfo)
			: base(model, sqlDialect, sqlDataTypeProvider, sqlQueryFormatterManager, contextInfo.DatabaseName, contextInfo)
		{
			this.SupportsPreparedTransactions = contextInfo.EnablePreparedTransactions;

			this.Host = contextInfo.ServerName;
			this.UserId = contextInfo.UserId;
			this.Password = contextInfo.Password;
			this.Port = contextInfo.Port;
			
			var connectionStringBuilder = new NpgsqlConnectionStringBuilder
			{
				Host = contextInfo.ServerName,
				Username = contextInfo.UserId,
				Password = contextInfo.Password,
				Port = contextInfo.Port,
				Pooling = contextInfo.Pooling,
				Enlist = false,
				MinPoolSize = contextInfo.MinPoolSize,
				MaxPoolSize = contextInfo.MaxPoolSize,
				KeepAlive = contextInfo.KeepAlive,
				ConnectionIdleLifetime = contextInfo.ConnectionIdleLifetime,
				ConvertInfinityDateTime = contextInfo.ConvertInfinityDateTime
			};

			if (contextInfo.Timeout != null)
			{
				connectionStringBuilder.Timeout = contextInfo.Timeout.Value;
			}

			if (contextInfo.ConnectionTimeout.HasValue)
			{
				connectionStringBuilder.Timeout = contextInfo.ConnectionTimeout.Value;
			}
			
			if (contextInfo.ConnectionCommandTimeout.HasValue)
			{
				connectionStringBuilder.CommandTimeout = contextInfo.ConnectionCommandTimeout.Value;
			}

			connectionStringBuilder.Database = contextInfo.DatabaseName;

			this.ConnectionString = connectionStringBuilder.ToString();

			connectionStringBuilder.Database = "postgres";

			this.ServerConnectionString = connectionStringBuilder.ToString();

			this.SchemaManager = new PostgresSqlDatabaseSchemaManager(this);
		}
コード例 #8
0
        protected PostgresSqlDatabaseContext(DataAccessModel model, SqlDialect sqlDialect, SqlDataTypeProvider sqlDataTypeProvider, SqlQueryFormatterManager sqlQueryFormatterManager, PostgresSqlDatabaseContextInfo contextInfo)
            : base(model, sqlDialect, sqlDataTypeProvider, sqlQueryFormatterManager, contextInfo.DatabaseName, contextInfo)
        {
            this.Host = contextInfo.ServerName;
            this.UserId = contextInfo.UserId;
            this.Password = contextInfo.Password;
            this.Port = contextInfo.Port;

            var connectionStringBuilder = new NpgsqlConnectionStringBuilder
            {
                Host = contextInfo.ServerName,
                Username = contextInfo.UserId,
                Password = contextInfo.Password,
                Port = contextInfo.Port,
                Pooling = contextInfo.Pooling,
                Enlist = false,
                BackendTimeouts = contextInfo.BackendTimeouts,
                MinPoolSize = contextInfo.MinPoolSize,
                MaxPoolSize = contextInfo.MaxPoolSize
            };

            if (contextInfo.ConnectionTimeout.HasValue)
            {
                connectionStringBuilder.Timeout = contextInfo.ConnectionTimeout.Value;
            }

            if (contextInfo.ConnectionCommandTimeout.HasValue)
            {
                connectionStringBuilder.CommandTimeout = contextInfo.ConnectionCommandTimeout.Value;
            }

            connectionStringBuilder.Database = contextInfo.DatabaseName;

            this.ConnectionString = connectionStringBuilder.ToString();

            connectionStringBuilder.Database = "postgres";

            this.ServerConnectionString = connectionStringBuilder.ToString();

            this.SchemaManager = new PostgresSqlDatabaseSchemaManager(this);
        }
コード例 #9
0
        protected PostgresSqlDatabaseContext(DataAccessModel model, SqlDialect sqlDialect, SqlDataTypeProvider sqlDataTypeProvider, SqlQueryFormatterManager sqlQueryFormatterManager, PostgresSqlDatabaseContextInfo contextInfo)
            : base(model, sqlDialect, sqlDataTypeProvider, sqlQueryFormatterManager, contextInfo.DatabaseName, contextInfo)
        {
            this.SupportsPreparedTransactions = contextInfo.EnablePreparedTransactions;

            this.Host     = contextInfo.ServerName;
            this.UserId   = contextInfo.UserId;
            this.Password = contextInfo.Password;
            this.Port     = contextInfo.Port;

            var connectionStringBuilder = new NpgsqlConnectionStringBuilder
            {
                Host                    = contextInfo.ServerName,
                Username                = contextInfo.UserId,
                Password                = contextInfo.Password,
                Port                    = contextInfo.Port,
                Pooling                 = contextInfo.Pooling,
                Enlist                  = false,
                MinPoolSize             = contextInfo.MinPoolSize,
                MaxPoolSize             = contextInfo.MaxPoolSize,
                KeepAlive               = contextInfo.KeepAlive,
                ConnectionIdleLifetime  = contextInfo.ConnectionIdleLifetime,
                ConvertInfinityDateTime = contextInfo.ConvertInfinityDateTime
            };

            if (contextInfo.Timeout != null)
            {
                connectionStringBuilder.Timeout = contextInfo.Timeout.Value;
            }

            if (contextInfo.ConnectionTimeout.HasValue)
            {
                connectionStringBuilder.Timeout = contextInfo.ConnectionTimeout.Value;
            }

            if (contextInfo.ConnectionCommandTimeout.HasValue)
            {
                connectionStringBuilder.CommandTimeout = contextInfo.ConnectionCommandTimeout.Value;
            }

            connectionStringBuilder.Database = contextInfo.DatabaseName;

            this.ConnectionString = connectionStringBuilder.ToString();

            connectionStringBuilder.Database = "postgres";

            this.ServerConnectionString = connectionStringBuilder.ToString();

            this.SchemaManager = new PostgresSqlDatabaseSchemaManager(this);
        }
コード例 #10
0
        protected PostgresSqlDatabaseContext(DataAccessModel model, SqlDialect sqlDialect, SqlDataTypeProvider sqlDataTypeProvider, SqlQueryFormatterManager sqlQueryFormatterManager, PostgresSqlDatabaseContextInfo contextInfo)
            : base(model, sqlDialect, sqlDataTypeProvider, sqlQueryFormatterManager, contextInfo.DatabaseName, contextInfo)
        {
            this.Host     = contextInfo.ServerName;
            this.UserId   = contextInfo.UserId;
            this.Password = contextInfo.Password;
            this.Port     = contextInfo.Port;

            var connectionStringBuilder = new NpgsqlConnectionStringBuilder
            {
                Host            = contextInfo.ServerName,
                Username        = contextInfo.UserId,
                Password        = contextInfo.Password,
                Port            = contextInfo.Port,
                Pooling         = contextInfo.Pooling,
                Enlist          = false,
                BackendTimeouts = contextInfo.BackendTimeouts,
                MinPoolSize     = contextInfo.MinPoolSize,
                MaxPoolSize     = contextInfo.MaxPoolSize
            };

            if (contextInfo.ConnectionTimeout.HasValue)
            {
                connectionStringBuilder.Timeout = contextInfo.ConnectionTimeout.Value;
            }

            if (contextInfo.ConnectionCommandTimeout.HasValue)
            {
                connectionStringBuilder.CommandTimeout = contextInfo.ConnectionCommandTimeout.Value;
            }

            connectionStringBuilder.Database = contextInfo.DatabaseName;

            this.ConnectionString = connectionStringBuilder.ToString();

            connectionStringBuilder.Database = "postgres";

            this.ServerConnectionString = connectionStringBuilder.ToString();

            this.SchemaManager = new PostgresSqlDatabaseSchemaManager(this);
        }
コード例 #11
0
        protected PostgresSqlDatabaseContext(DataAccessModel model, SqlDialect sqlDialect, SqlDataTypeProvider sqlDataTypeProvider, SqlQueryFormatterManager sqlQueryFormatterManager, PostgresSqlDatabaseContextInfo contextInfo)
            : base(model, sqlDialect, sqlDataTypeProvider, sqlQueryFormatterManager, contextInfo.DatabaseName, contextInfo)
        {
            this.Host           = contextInfo.ServerName;
            this.UserId         = contextInfo.UserId;
            this.Password       = contextInfo.Password;
            this.Port           = contextInfo.Port;
            this.CommandTimeout = TimeSpan.FromSeconds(contextInfo.CommandTimeout);

            this.ConnectionString       = String.Format("Host={0};User Id={1};Password={2};Database={3};Port={4};Pooling={5};MinPoolSize={6};MaxPoolSize={7};Enlist=false;Timeout={8};CommandTimeout={9}", contextInfo.ServerName, contextInfo.UserId, contextInfo.Password, contextInfo.DatabaseName, contextInfo.Port, contextInfo.Pooling, contextInfo.MinPoolSize, contextInfo.MaxPoolSize, contextInfo.ConnectionTimeout, contextInfo.CommandTimeout);
            this.ServerConnectionString = Regex.Replace(this.ConnectionString, @"Database\s*\=[^;]+[;$]", "Database=postgres;");

            this.SchemaManager = new PostgresSharedSqlDatabaseSchemaManager(this);
        }