Beispiel #1
0
 /// <summary>
 /// Checks exception for Sql related exceptions and attempts to transform it to RhetosException
 /// </summary>
 public static RhetosException InterpretSqlException(Exception exception)
 {
     if (DatabaseLanguageIsMsSql.Value)
     {
         return(MsSqlUtility.InterpretSqlException(exception));
     }
     else if (DatabaseLanguageIsOracle.Value)
     {
         return(OracleSqlUtility.InterpretSqlException(exception));
     }
     else
     {
         return(null);
     }
 }
 public static string GetSchemaName(string fullObjectName)
 {
     if (_databaseLanguageIsMsSql)
     {
         return(MsSqlUtility.GetSchemaName(fullObjectName));
     }
     else if (_databaseLanguageIsOracle)
     {
         return(OracleSqlUtility.GetSchemaName(fullObjectName));
     }
     else
     {
         throw new FrameworkException(UnsupportedLanguageError);
     }
 }
Beispiel #3
0
        private static DateTime GetDatabaseTimeFromDatabase(ISqlExecuter sqlExecuter)
        {
            DateTime now;

            if (DatabaseLanguageIsMsSql.Value)
            {
                now = MsSqlUtility.GetDatabaseTime(sqlExecuter);
            }
            else if (DatabaseLanguageIsOracle.Value)
            {
                throw new FrameworkException("GetDatabaseTime function is not yet supported in Rhetos for Oracle database.");
            }
            else
            {
                throw new FrameworkException(UnsupportedLanguageError);
            }
            return(DateTime.SpecifyKind(now, DateTimeKind.Local));
        }
Beispiel #4
0
 public static DateTime GetDatabaseTime(ISqlExecuter sqlExecuter)
 {
     return(DatabaseTimeCache.GetDatabaseTimeCached(() =>
     {
         DateTime databaseTime;
         if (DatabaseLanguageIsMsSql.Value)
         {
             databaseTime = MsSqlUtility.GetDatabaseTime(sqlExecuter);
         }
         else if (DatabaseLanguageIsOracle.Value)
         {
             throw new FrameworkException("GetDatabaseTime function is not yet supported in Rhetos for Oracle database.");
         }
         else
         {
             throw new FrameworkException(UnsupportedLanguageError);
         }
         return DateTime.SpecifyKind(databaseTime, DateTimeKind.Local);
     }, () => DateTime.Now));
 }
Beispiel #5
0
        /// <summary>
        /// Throws an exception if 'name' is not a valid SQL database object name.
        /// Function returns given argument so it can be used as fluent interface.
        /// In some cases the function may change the identifier (limit identifier length to 30 on Oracle database, e.g.).
        /// </summary>
        public static string Identifier(string name)
        {
            string error = CsUtility.GetIdentifierError(name);

            if (error != null)
            {
                throw new FrameworkException("Invalid database object name: " + error);
            }

            if (DatabaseLanguageIsOracle.Value)
            {
                name = OracleSqlUtility.LimitIdentifierLength(name);
            }
            if (DatabaseLanguageIsMsSql.Value)
            {
                name = MsSqlUtility.LimitIdentifierLength(name);
            }

            return(name);
        }