public static SchemaExtendedReader Create(string connectionString, SqlType sqlType)
 {
     SchemaExtendedReader schemaReader;
     switch (sqlType)
     {
         case SqlType.Oracle:
             schemaReader = new OracleSchemaReader(connectionString, "System.Data.OracleClient");
             break;
         case SqlType.SqlServer:
             schemaReader = new SqlAzureOrSqlServerSchemaReader(connectionString, "System.Data.SqlClient");
             break;
         case SqlType.SqlServerCe:
             schemaReader = new SqlServerCeSchemaReader(connectionString, "System.Data.SqlServerCe.4.0");
             break;
         case SqlType.MySql:
             schemaReader = new MySqlSchemaReader(connectionString, "MySql.Data.MySqlClient");
             break;
         case SqlType.PostgreSql:
             schemaReader = new PostgreSqlSchemaReader(connectionString, "Npgsql");
             break;
         case SqlType.Db2:
             schemaReader = new Db2SchemaReader(connectionString, "IBM.Data.DB2");
             break;
         case SqlType.SQLite:
             schemaReader = new SchemaExtendedReader(connectionString, "System.Data.SQLite");
             break;
         default:
             throw new ArgumentOutOfRangeException("sqlType", "Not a recognized SqlType");
     }
     return schemaReader;
 }
        public void TriggerWithNoQuotes()
        {
            //arrange
            var osr = new OracleSchemaReader(ConnectionStrings.OracleHr, "System.Data.OracleClient");
            var dt = new DatabaseTable();
            dt
                .AddColumn("ID")
                .AddPrimaryKey()
                .AddColumn("NAME");
            dt.Triggers.Add(new DatabaseTrigger
            {
                //with spaces, line breaks
                TriggerBody = @"BEGIN
    SELECT MY_SEQ.NEXTVAL
    INTO :NEW.ID
    FROM DUAL;
END;"
            });

            //act
            osr.PostProcessing(dt);

            //assert
            Assert.IsTrue(dt.HasAutoNumberColumn);
        }
        public void NoTriggers()
        {
            //arrange
            var osr = new OracleSchemaReader(ConnectionStrings.OracleHr, "System.Data.OracleClient");
            var dt = new DatabaseTable();
            dt
                .AddColumn("ID")
                .AddPrimaryKey()
                .AddColumn("NAME");

            //act
            osr.PostProcessing(dt);

            //assert
            Assert.IsFalse(dt.HasAutoNumberColumn);

        }
        public void TriggerWithQuotes()
        {
            //arrange
            var osr = new OracleSchemaReader(ConnectionStrings.OracleHr, "System.Data.OracleClient");
            var dt = new DatabaseTable();
            dt
                .AddColumn("ID")
                .AddPrimaryKey()
                .AddColumn("NAME");
            dt.Triggers.Add(new DatabaseTrigger
            {
                //generated by SqlDeveloper
                TriggerBody = @"CREATE OR REPLACE TRIGGER ""DB"".""MYTRIGGER"" before insert on ""DB"".""TABLE1""    for each row begin     if inserting then       if :NEW.""ID"" is null then          select MY_SEQ.nextval into :NEW.""ID"" from dual;       end if;    end if; end;"
            });

            //act
            osr.PostProcessing(dt);

            //assert
            Assert.IsTrue(dt.HasAutoNumberColumn);
        }
Exemple #5
0
        public static SchemaExtendedReader Create(string connectionString, SqlType sqlType)
        {
            SchemaExtendedReader schemaReader;

            switch (sqlType)
            {
            case SqlType.Oracle:
                schemaReader = new OracleSchemaReader(connectionString, "System.Data.OracleClient");
                break;

            case SqlType.SqlServer:
                schemaReader = new SqlAzureOrSqlServerSchemaReader(connectionString, "System.Data.SqlClient");
                break;

            case SqlType.SqlServerCe:
                schemaReader = new SqlServerCeSchemaReader(connectionString, "System.Data.SqlServerCe.4.0");
                break;

            case SqlType.MySql:
                schemaReader = new MySqlSchemaReader(connectionString, "MySql.Data.MySqlClient");
                break;

            case SqlType.PostgreSql:
                schemaReader = new PostgreSqlSchemaReader(connectionString, "Npgsql");
                break;

            case SqlType.Db2:
                schemaReader = new Db2SchemaReader(connectionString, "IBM.Data.DB2");
                break;

            case SqlType.SQLite:
                schemaReader = new SchemaExtendedReader(connectionString, "System.Data.SQLite");
                break;

            default:
                throw new ArgumentOutOfRangeException("sqlType", "Not a recognized SqlType");
            }
            return(schemaReader);
        }
        public static SchemaExtendedReader Create(string connectionString, string providerName)
        {
            if (string.IsNullOrEmpty(providerName))
                throw new ArgumentNullException("providerName", "providerName must not be empty");

            SchemaExtendedReader schemaReader = null;
            var type = ProviderToSqlType.Convert(providerName);
            switch (type)
            {
                case SqlType.Oracle:
                    schemaReader = new OracleSchemaReader(connectionString, providerName);
                    break;
                case SqlType.SqlServer:
                    schemaReader = new SqlAzureOrSqlServerSchemaReader(connectionString, providerName);
                    break;
                case SqlType.SqlServerCe:
                    schemaReader = new SqlServerCeSchemaReader(connectionString, providerName);
                    break;
                case SqlType.MySql:
                    schemaReader = new MySqlSchemaReader(connectionString, providerName);
                    break;
                case SqlType.PostgreSql:
                    schemaReader = new PostgreSqlSchemaReader(connectionString, providerName);
                    break;
                case SqlType.Db2:
                    schemaReader = new Db2SchemaReader(connectionString, providerName);
                    break;
                default:
                    //all the other types
                    if (providerName.Equals("Ingres.Client", StringComparison.OrdinalIgnoreCase))
                    {
                        schemaReader = new IngresSchemaReader(connectionString, providerName);
                    }
                    else if (providerName.Equals("iAnyWhere.Data.SQLAnyWhere", StringComparison.OrdinalIgnoreCase))
                    {
                        schemaReader = new SybaseAsaSchemaReader(connectionString, providerName);
                    }
                    else if (providerName.Equals("Sybase.Data.AseClient", StringComparison.OrdinalIgnoreCase))
                    {
                        schemaReader = new SybaseAseSchemaReader(connectionString, providerName);
                    }
                    else if (providerName.Equals("iAnyWhere.Data.UltraLite", StringComparison.OrdinalIgnoreCase))
                    {
                        schemaReader = new SybaseUltraLiteSchemaReader(connectionString, providerName);
                    }
                    else if (providerName.Equals("System.Data.OleDb", StringComparison.OrdinalIgnoreCase))
                    {
                        schemaReader = new OleDbSchemaReader(connectionString, providerName);
                    }
                    else if (providerName.Equals("System.Data.VistaDB", StringComparison.OrdinalIgnoreCase))
                    {
                        schemaReader = new VistaDbSchemaReader(connectionString, providerName);
                    }
                    else if (providerName.Equals("IBM.Data.DB2.iSeries", StringComparison.OrdinalIgnoreCase))
                    {
                        schemaReader = new Db2ISeriesSchemaReader(connectionString, providerName);
                    }
                    else if (providerName.Equals("FirebirdSql.Data.FirebirdClient", StringComparison.OrdinalIgnoreCase))
                    {
                        schemaReader = new FirebirdSqlSchemaReader(connectionString, providerName);
                    }

                    break;
            }
            if (schemaReader == null)
            {
                schemaReader = new SchemaExtendedReader(connectionString, providerName);
            }
            return schemaReader;
        }
Exemple #7
0
        public static SchemaExtendedReader Create(string connectionString, string providerName)
        {
            if (string.IsNullOrEmpty(providerName))
            {
                throw new ArgumentNullException("providerName", "providerName must not be empty");
            }

            SchemaExtendedReader schemaReader = null;
            var type = ProviderToSqlType.Convert(providerName);

            switch (type)
            {
            case SqlType.Oracle:
                schemaReader = new OracleSchemaReader(connectionString, providerName);
                break;

            case SqlType.SqlServer:
                schemaReader = new SqlAzureOrSqlServerSchemaReader(connectionString, providerName);
                break;

            case SqlType.SqlServerCe:
                schemaReader = new SqlServerCeSchemaReader(connectionString, providerName);
                break;

            case SqlType.MySql:
                schemaReader = new MySqlSchemaReader(connectionString, providerName);
                break;

            case SqlType.PostgreSql:
                schemaReader = new PostgreSqlSchemaReader(connectionString, providerName);
                break;

            case SqlType.Db2:
                schemaReader = new Db2SchemaReader(connectionString, providerName);
                break;

            default:
                //all the other types
                if (providerName.Equals("Ingres.Client", StringComparison.OrdinalIgnoreCase))
                {
                    schemaReader = new IngresSchemaReader(connectionString, providerName);
                }
                else if (providerName.Equals("iAnyWhere.Data.SQLAnyWhere", StringComparison.OrdinalIgnoreCase))
                {
                    schemaReader = new SybaseAsaSchemaReader(connectionString, providerName);
                }
                else if (providerName.Equals("Sybase.Data.AseClient", StringComparison.OrdinalIgnoreCase))
                {
                    schemaReader = new SybaseAseSchemaReader(connectionString, providerName);
                }
                else if (providerName.Equals("iAnyWhere.Data.UltraLite", StringComparison.OrdinalIgnoreCase))
                {
                    schemaReader = new SybaseUltraLiteSchemaReader(connectionString, providerName);
                }
                else if (providerName.Equals("System.Data.OleDb", StringComparison.OrdinalIgnoreCase))
                {
                    schemaReader = new OleDbSchemaReader(connectionString, providerName);
                }
                else if (providerName.Equals("System.Data.VistaDB", StringComparison.OrdinalIgnoreCase))
                {
                    schemaReader = new VistaDbSchemaReader(connectionString, providerName);
                }
                else if (providerName.Equals("IBM.Data.DB2.iSeries", StringComparison.OrdinalIgnoreCase))
                {
                    schemaReader = new Db2ISeriesSchemaReader(connectionString, providerName);
                }

                break;
            }
            if (schemaReader == null)
            {
                schemaReader = new SchemaExtendedReader(connectionString, providerName);
            }
            return(schemaReader);
        }