Inheritance: Shaolinq.Persistence.SqlDatabaseContextInfo
Exemplo n.º 1
0
        public static PostgresDotConnectSqlDatabaseContext Create(PostgresDotConnectSqlDatabaseContextInfo 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, false));

            return(new PostgresDotConnectSqlDatabaseContext(model, sqlDialect, sqlDataTypeProvider, sqlQueryFormatterManager, contextInfo));
        }
 public static DataAccessModelConfiguration Create(PostgresDotConnectSqlDatabaseContextInfo contextInfo)
 {
     return(new DataAccessModelConfiguration
     {
         SqlDatabaseContextInfos = new SqlDatabaseContextInfo[]
         {
             contextInfo
         }
     });
 }
        public static PostgresDotConnectSqlDatabaseContext Create(PostgresDotConnectSqlDatabaseContextInfo contextInfo, DataAccessModel model)
        {
            var constraintDefaults       = model.Configuration.ConstraintDefaultsConfiguration;
            var sqlDialect               = new PostgresDotConnectSqlDialect();
            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 PostgresDotConnectSqlQueryFormatter(options, sqlDialect, sqlDataTypeProvider, typeDescriptorProvider, contextInfo.SchemaName, false));

            return(new PostgresDotConnectSqlDatabaseContext(model, sqlDialect, sqlDataTypeProvider, sqlQueryFormatterManager, contextInfo));
        }
 public static DataAccessModelConfiguration Create(PostgresDotConnectSqlDatabaseContextInfo contextInfo)
 {
     return new DataAccessModelConfiguration
     {
         SqlDatabaseContextInfos = new SqlDatabaseContextInfo[]
         {
             contextInfo
         }
     };
 }
		public static PostgresDotConnectSqlDatabaseContext Create(PostgresDotConnectSqlDatabaseContextInfo contextInfo, DataAccessModel model)
		{
			var constraintDefaults = model.Configuration.ConstraintDefaultsConfiguration;
			var sqlDialect = new PostgresDotConnectSqlDialect();
			var sqlDataTypeProvider = new PostgresSqlDataTypeProvider(model.TypeDescriptorProvider, constraintDefaults, contextInfo.NativeUuids, contextInfo.NativeEnums);
			var typeDescriptorProvider = model.TypeDescriptorProvider;
			var sqlQueryFormatterManager = new DefaultSqlQueryFormatterManager(sqlDialect, (options) => new PostgresDotConnectSqlQueryFormatter(options, sqlDialect, sqlDataTypeProvider, typeDescriptorProvider, contextInfo.SchemaName, false));

			return new PostgresDotConnectSqlDatabaseContext(model, sqlDialect, sqlDataTypeProvider, sqlQueryFormatterManager, contextInfo);
		}
        protected PostgresDotConnectSqlDatabaseContext(DataAccessModel model, SqlDialect sqlDialect, SqlDataTypeProvider sqlDataTypeProvider, SqlQueryFormatterManager sqlQueryFormatterManager, PostgresDotConnectSqlDatabaseContextInfo contextInfo)
            : base(model, sqlDialect, sqlDataTypeProvider, sqlQueryFormatterManager, contextInfo.DatabaseName, contextInfo)
        {
            if (!string.IsNullOrEmpty(contextInfo.ConnectionString))
            {
                this.ConnectionString = contextInfo.ConnectionString;
                this.ServerConnectionString = Regex.Replace(this.ConnectionString, @"Database\s*\=[^;$]+[;$]", "");
            }
            else
            {
                this.Host = contextInfo.ServerName;
                this.UserId = contextInfo.UserId;
                this.Password = contextInfo.Password;
                this.Port = contextInfo.Port;

                var connectionStringBuilder = new PgSqlConnectionStringBuilder
                {
                    Host = contextInfo.ServerName,
                    UserId = contextInfo.UserId,
                    Password = contextInfo.Password,
                    Port = contextInfo.Port,
                    Pooling = contextInfo.Pooling,
                    Enlist = false,
                    Charset = "UTF8",
                    Unicode = true,
                    MaxPoolSize = contextInfo.MaxPoolSize,
                    UnpreparedExecute = contextInfo.UnpreparedExecute
                };

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

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

                this.ServerConnectionString = connectionStringBuilder.ConnectionString;
                connectionStringBuilder.Database = contextInfo.DatabaseName;
                this.ConnectionString = connectionStringBuilder.ConnectionString;
            }

            this.SchemaManager = new PostgresSqlDatabaseSchemaManager(this);
        }
Exemplo n.º 7
0
        protected PostgresDotConnectSqlDatabaseContext(DataAccessModel model, SqlDialect sqlDialect, SqlDataTypeProvider sqlDataTypeProvider, SqlQueryFormatterManager sqlQueryFormatterManager, PostgresDotConnectSqlDatabaseContextInfo contextInfo)
            : base(model, sqlDialect, sqlDataTypeProvider, sqlQueryFormatterManager, contextInfo.DatabaseName, contextInfo)
        {
            if (!string.IsNullOrEmpty(contextInfo.ConnectionString))
            {
                this.ConnectionString       = contextInfo.ConnectionString;
                this.ServerConnectionString = Regex.Replace(this.ConnectionString, @"Database\s*\=[^;$]+[;$]", "");
            }
            else
            {
                this.Host     = contextInfo.ServerName;
                this.UserId   = contextInfo.UserId;
                this.Password = contextInfo.Password;
                this.Port     = contextInfo.Port;

                var connectionStringBuilder = new PgSqlConnectionStringBuilder
                {
                    Host              = contextInfo.ServerName,
                    UserId            = contextInfo.UserId,
                    Password          = contextInfo.Password,
                    Port              = contextInfo.Port,
                    Pooling           = contextInfo.Pooling,
                    Enlist            = false,
                    Charset           = "UTF8",
                    Unicode           = true,
                    MaxPoolSize       = contextInfo.MaxPoolSize,
                    UnpreparedExecute = contextInfo.UnpreparedExecute
                };

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

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

                this.ServerConnectionString      = connectionStringBuilder.ConnectionString;
                connectionStringBuilder.Database = contextInfo.DatabaseName;
                this.ConnectionString            = connectionStringBuilder.ConnectionString;
            }

            this.SchemaManager = new PostgresSqlDatabaseSchemaManager(this);
        }
        public static PostgresDotConnectSqlDatabaseContext Create(PostgresDotConnectSqlDatabaseContextInfo contextInfo, DataAccessModel model)
        {
            var constraintDefaults = model.Configuration.ConstraintDefaults;
            var sqlDialect = PostgresSharedSqlDialect.Default;
            var sqlDataTypeProvider = new PostgresDotConnectSqlDataTypeProvider(constraintDefaults, contextInfo.NativeUuids, contextInfo.NativeEnums, !contextInfo.UnpreparedExecute);
            var sqlQueryFormatterManager = new DefaultSqlQueryFormatterManager(sqlDialect, sqlDataTypeProvider, (options, sqlDataTypeProviderArg, sqlDialectArg) => new PostgresSharedSqlQueryFormatter(options, sqlDataTypeProviderArg, sqlDialectArg, contextInfo.SchemaName));

            return new PostgresDotConnectSqlDatabaseContext(model, sqlDialect, sqlDataTypeProvider, sqlQueryFormatterManager, contextInfo);
        }