Esempio n. 1
0
        private static void CheckIfAuditTableExists(Type auditRecordType, DatabaseType databaseType)
        {
            var classConfig = ClassConfigContainer.FindClassConfig(auditRecordType);

            var table = classConfig.TableName;

            var sql = string.Empty;

            if (databaseType != DatabaseType.Oracle)
            {
                sql = string.Format("SELECT COUNT(*) " +
                                    "FROM INFORMATION_SCHEMA.TABLES " +
                                    "WHERE TABLE_SCHEMA = '[Schema]'   AND  TABLE_NAME = '{0}'  OR   TABLE_NAME = '{1}' ",
                                    table.ToLower(), table);
            }
            else
            {
                sql = string.Format("SELECT COUNT(*) FROM  ALL_TABLES  WHERE OWNER ='[Schema]'  AND TABLE_NAME ='{0}'",
                                    table);
            }


            var database = DatabaseCreator.CreateDatabase();

            var result = database.ExecuteScalar(sql);

            if (result.ToString() == "0")
            {
                throw new EasylinkException("Audit table {0} does not exist in the database.", table);
            }
        }
Esempio n. 2
0
        public static IDatabase Create()
        {
            if (DatabaseSetup.Instance == null)
            {
                InitializeDatabaseFactory();
            }

            return(DatabaseCreator.CreateDatabase());
        }