Beispiel #1
0
        protected virtual bool TryGetProviderSpecificProperties(string provider, DBDatabase database, out DBDatabaseProperties props)
        {
            props = null;
            switch (provider.ToLower())
            {
            case ("microsoft.ace.oledb.12.0"):
                string datasource = GetDataSourceNameFromConnection(database, ';', '=', "data source");

                if (!string.IsNullOrEmpty(datasource))
                {
                    if (datasource.StartsWith("\""))
                    {
                        datasource = datasource.Substring(1, datasource.Length - 2);
                    }

                    datasource = System.IO.Path.GetFileNameWithoutExtension(datasource);
                }
                TypedOperationCollection unsupported = new TypedOperationCollection();
                this.FillNotSupported(unsupported);

                props = new DBDatabaseProperties(datasource, MSAccessProductName, "Microsoft", "OLEDB", "?", new Version("12.0"),
                                                 SupportedSchemaOptions.TablesViewsAndIndexes | DBSchemaTypes.StoredProcedure, false, DBParameterLayout.Positional,
                                                 SUPPORTED_ACCESS_TYPES, new TopType[] { TopType.Count },
                                                 Schema.DBSchemaInformation.CreateDefault(), unsupported);
                break;

            default:
                break;
            }
            return(props != null);
        }
Beispiel #2
0
        protected override void FillNotSupported(TypedOperationCollection all)
        {
            all.Add(new TypedOperation(DBSchemaTypes.CommandScripts, DBSchemaOperation.CheckExists));
            all.Add(new TypedOperation(DBSchemaTypes.Database, DBSchemaOperation.CheckExists));
            all.Add(new TypedOperation(DBSchemaTypes.ForeignKey, DBSchemaOperation.CheckExists));
            all.Add(new TypedOperation(DBSchemaTypes.Function, DBSchemaOperation.CheckExists));
            all.Add(new TypedOperation(DBSchemaTypes.Group, DBSchemaOperation.CheckExists));
            all.Add(new TypedOperation(DBSchemaTypes.Index, DBSchemaOperation.CheckExists));
            all.Add(new TypedOperation(DBSchemaTypes.StoredProcedure, DBSchemaOperation.CheckExists));
            all.Add(new TypedOperation(DBSchemaTypes.Table, DBSchemaOperation.CheckExists));
            all.Add(new TypedOperation(DBSchemaTypes.User, DBSchemaOperation.CheckExists));
            all.Add(new TypedOperation(DBSchemaTypes.View, DBSchemaOperation.CheckExists));

            all.Add(new TypedOperation(DBSchemaTypes.CommandScripts, DBSchemaOperation.CheckNotExists));
            all.Add(new TypedOperation(DBSchemaTypes.Database, DBSchemaOperation.CheckNotExists));
            all.Add(new TypedOperation(DBSchemaTypes.ForeignKey, DBSchemaOperation.CheckNotExists));
            all.Add(new TypedOperation(DBSchemaTypes.Function, DBSchemaOperation.CheckNotExists));
            all.Add(new TypedOperation(DBSchemaTypes.Group, DBSchemaOperation.CheckNotExists));
            all.Add(new TypedOperation(DBSchemaTypes.Index, DBSchemaOperation.CheckExists));
            all.Add(new TypedOperation(DBSchemaTypes.StoredProcedure, DBSchemaOperation.CheckNotExists));
            all.Add(new TypedOperation(DBSchemaTypes.Table, DBSchemaOperation.CheckNotExists));
            all.Add(new TypedOperation(DBSchemaTypes.User, DBSchemaOperation.CheckNotExists));
            all.Add(new TypedOperation(DBSchemaTypes.View, DBSchemaOperation.CheckNotExists));

            base.FillNotSupported(all);
        }
Beispiel #3
0
        protected override DBDatabaseProperties GetPropertiesFromDb(DBDatabase forDatabase)
        {
            string db;
            string vers;

            using (DbCommand cmd = forDatabase.CreateCommand("SELECT sqlite_version()", CommandType.Text))
            {
                object versValue = forDatabase.ExecuteScalar(cmd);
                db   = cmd.Connection.Database;
                vers = (null == versValue) ? string.Empty : versValue.ToString();
            }

            string dbname = GetDataSourceNameFromConnection(forDatabase);
            TypedOperationCollection unsupported = new TypedOperationCollection();

            this.FillNotSupported(unsupported);

            DBDatabaseProperties props = new DBDatabaseProperties(dbname, "SQLite", db, "", "@{0}", new Version(vers),
                                                                  SupportedSchemaOptions.TablesViewsAndIndexes | DBSchemaTypes.CommandScripts, false,
                                                                  DBParameterLayout.Named, SUPPORTED_TYPES, new TopType[] { TopType.Count, TopType.Range },
                                                                  Schema.DBSchemaInformation.CreateDefault(),
                                                                  unsupported);

            return(props);
        }
 protected override void FillNotSupported(TypedOperationCollection all)
 {
     base.FillNotSupported(all);
     all.Add(new TypedOperation(DBSchemaTypes.Index, DBSchemaOperation.CheckExists));
     all.Add(new TypedOperation(DBSchemaTypes.Index, DBSchemaOperation.CheckNotExists));
     all.Add(new TypedOperation(DBSchemaTypes.View, DBSchemaOperation.CheckNotExists));
 }
Beispiel #5
0
        protected override DBDatabaseProperties GetPropertiesFromDb(DBDatabase forDatabase)
        {
            TypedOperationCollection unsupported = new TypedOperationCollection();

            this.FillNotSupported(unsupported);
            return(new DBDatabaseProperties(forDatabase.Name, "Oracle", "?", "?", ":{0}", new Version(0, 0),
                                            SupportedSchemaOptions.All & ~DBSchemaTypes.CommandScripts, true, DBParameterLayout.Named,
                                            SUPPORTED_TYPES, SUPPORTED_TOP_TYPES,
                                            Schema.DBSchemaInformation.CreateOracle(), unsupported));
        }
Beispiel #6
0
        protected override DBDatabaseProperties GetPropertiesFromDb(DBDatabase forDatabase)
        {
            string statement = "SELECT  SERVERPROPERTY('productversion') AS [version], SERVERPROPERTY ('productlevel') AS [level], SERVERPROPERTY ('edition') AS [edition]";
            DBDatabaseProperties props;

            System.Data.SqlClient.SqlConnectionStringBuilder builder = new System.Data.SqlClient.SqlConnectionStringBuilder(forDatabase.ConnectionString);
            string dbname = builder.InitialCatalog;

            if (string.IsNullOrEmpty(dbname))
            {
                dbname = builder.DataSource;
            }


            TypedOperationCollection unsupported = new TypedOperationCollection();

            this.FillNotSupported(unsupported);

            DBSchemaInformation info = DBSchemaInformation.CreateDefault();

            TopType[] tops          = new TopType[] { TopType.Count, TopType.Percent, TopType.Range };
            bool      caseSensitive = false;
            string    level         = "?";
            string    edition       = "?";
            Version   version       = new Version(1, 0);

            forDatabase.ExecuteRead(statement, reader =>
            {
                if (reader.Read())
                {
                    level   = reader["level"].ToString();
                    edition = reader["edition"].ToString();
                    version = new Version(reader["version"].ToString());
                }
            });

            props = new DBDatabaseProperties(dbname, "SQL Server",
                                             level,
                                             edition,
                                             "@{0}",
                                             version,
                                             SupportedSchemaOptions.All,
                                             caseSensitive,
                                             DBParameterLayout.Named,
                                             SUPPORTED_TYPES, tops,
                                             info,
                                             unsupported);
            props.TemporaryTableConstruct = "";
            props.TemporaryTablePrefix    = "#";
            return(props);
        }
Beispiel #7
0
        protected override DBDatabaseProperties GetPropertiesFromDb(DBDatabase forDatabase)
        {
            TypedOperationCollection unsupported = new TypedOperationCollection();

            this.FillNotSupported(unsupported);

            DBSchemaInformation info = DBSchemaInformation.CreateDefault();

            TopType[] tops          = new TopType[] { TopType.Count, TopType.Percent, TopType.Range };
            bool      caseSensitive = false;
            string    level         = "?";
            string    edition       = "?";
            string    database      = "?";
            Version   version       = new Version(1, 0);

            string statement = "SELECT  SERVERPROPERTY('productversion') AS [version], SERVERPROPERTY ('productlevel') AS [level], SERVERPROPERTY ('edition') AS [edition], DB_NAME() As [currentdatabase]";

            forDatabase.ExecuteRead(statement, reader =>
            {
                if (reader.Read())
                {
                    level    = reader["level"].ToString();
                    edition  = reader["edition"].ToString();
                    version  = new Version(reader["version"].ToString());
                    database = reader["currentdatabase"].ToString();
                }
            });

            DBDatabaseProperties props = new DBDatabaseProperties(database, "SQL Server",
                                                                  level,
                                                                  edition,
                                                                  "?",
                                                                  version,
                                                                  SupportedSchemaOptions.All,
                                                                  caseSensitive,
                                                                  DBParameterLayout.Positional,
                                                                  SUPPORTED_TYPES, tops,
                                                                  info,
                                                                  unsupported);

            props.TemporaryTableConstruct = "";
            props.TemporaryTablePrefix    = "#";
            return(props);
        }
        protected override DBDatabaseProperties GetPropertiesFromDb(DBDatabase forDatabase)
        {
            DBDatabaseProperties props = null;
            string vers;
            string edition = string.Empty;

            string db = this.GetDataSourceNameFromConnection(forDatabase, ';', '=', "Database");

            string versionFunction = "SELECT VERSION()";

            try
            {
                object value = forDatabase.ExecuteScalar(versionFunction, System.Data.CommandType.Text);
                vers = Convert.ToString(value);
                //format of the version is similar to '5.0.87-standard'
                if (string.IsNullOrEmpty(vers) == false)
                {
                    int index = vers.IndexOf('-');
                    if (index > -1)
                    {
                        edition = vers.Substring(index + 1).Trim();
                        vers    = vers.Substring(0, index - 1);
                    }
                }
                TypedOperationCollection unsupported = new TypedOperationCollection();


                props = new DBDatabaseProperties(db, "MySql",
                                                 string.Empty,
                                                 edition, "?{0}",
                                                 new Version(vers),
                                                 SupportedSchemaOptions.All,
                                                 false, DBParameterLayout.Named,
                                                 SUPPORTED_TYPES, SUPPORTED_TOPTYPES,
                                                 DBSchemaInformation.CreateDefault(),
                                                 unsupported
                                                 );
            }
            catch (Exception ex)
            {
                throw new System.Data.DataException(Errors.CannotGetPropertiesFromDB, ex);
            }
            return(props);
        }
Beispiel #9
0
        protected override DBDatabaseProperties GetPropertiesFromDb(DBDatabase forDatabase)
        {
            string con = forDatabase.ConnectionString;
            //looking for 'Provider=Microsoft.ACE.OLEDB.12.0;'
            int    index    = con.IndexOf("Provider=");
            string provider = string.Empty;

            if (index > -1)
            {
                provider = con.Substring(index + "Provider=".Length);
                index    = provider.IndexOf(';');
                if (index > 0)
                {
                    provider = provider.Substring(0, index);
                }
                else
                {
                    provider = string.Empty;
                }
            }
            DBDatabaseProperties props;

            if (!string.IsNullOrEmpty(provider))
            {
                if (this.TryGetProviderSpecificProperties(provider, forDatabase, out props))
                {
                    return(props);
                }
            }

            TypedOperationCollection unsupported = new TypedOperationCollection();

            this.FillNotSupported(unsupported);
            string datasource = GetDataSourceNameFromConnection(forDatabase, ';', '=', "data source");

            props = new DBDatabaseProperties(datasource, "OleDb", "?", "?", "?{0}", new Version("0.0"),
                                             SupportedSchemaOptions.TablesViewsAndIndexes, false, DBParameterLayout.Positional,
                                             SUPPORTED_TYPES, new TopType[] { TopType.Count },
                                             DBSchemaInformation.CreateDefault(), unsupported);
            return(props);
        }
Beispiel #10
0
 /// <summary>
 /// Adds the CreateOn for indexes - cannot use the CREATE INDEX [Name] ON TABLE only supports CREATE INDEX [Name]
 /// </summary>
 /// <param name="all"></param>
 protected override void FillNotSupported(TypedOperationCollection all)
 {
     all.Add(DBSchemaTypes.Index, DBSchemaOperation.CreateOn);
     base.FillNotSupported(all);
 }