Exemplo n.º 1
0
        public Type MapDbToClr(string dbType)
        {
            switch (dbType)
            {
            case "CHAR":
            case "VARCHAR":
            case "VARCHAR2":
            case "ROWID":
            case "LONG":
            case "CLOB":
                return(typeof(string));

            case "NUMBER":
                return(typeof(decimal));

            case "DATE":
                return(typeof(DateTime));

            case "BLOB":
            case "RAW":
                return(typeof(byte[]));

            default:
                GenerateExceptionHelper.ThrowUnknownMapType(dbType);
                return(typeof(void));
            }
        }
Exemplo n.º 2
0
        public string MapClrToDb(Type clrType)
        {
            if (clrType.IsGenericType && clrType.GetGenericTypeDefinition() == typeof(Nullable <>))
            {
                clrType = Nullable.GetUnderlyingType(clrType);
            }

            if (clrType.IsEnum)
            {
                return(" int ");
            }

            switch (Type.GetTypeCode(clrType))
            {
            case TypeCode.String:
            case TypeCode.Char:
                return(" nvarchar");

            case TypeCode.Int16:
            case TypeCode.Int32:
            case TypeCode.UInt16:
            case TypeCode.UInt32:
                return(" int ");

            case TypeCode.Int64:
            case TypeCode.UInt64:
                return(" long ");

            case TypeCode.DateTime:
                return(" datetime ");

            case TypeCode.Boolean:
                return(" bit ");

            case TypeCode.Decimal:
                return(" decimal ");

            case TypeCode.Single:
                return(" real ");

            case TypeCode.Byte:
                return(" tinyint ");

            default:
                if (clrType == typeof(Guid))
                {
                    return(" uniqueidentifier ");
                }
                else if (clrType == typeof(byte[]))
                {
                    return(" binary ");
                }
                else
                {
                    GenerateExceptionHelper.ThrowUnknownMapType(clrType);
                    return(string.Empty);
                }
            }
        }
Exemplo n.º 3
0
        public Type MapDbToClr(string dbType)
        {
            switch (dbType)
            {
            case "int":
            case "int identity":
                return(typeof(int));

            case "bigint":
                return(typeof(long));

            case "bit":
                return(typeof(bool));

            case "decimal":
            case "numeric":
                return(typeof(decimal));

            case "varchar":
            case "nvarchar":
            case "char":
            case "nchar":
            case "text":
                return(typeof(string));

            case "float":
                return(typeof(double));

            case "real":
                return(typeof(float));

            case "uniqueidentifier":
                return(typeof(Guid));

            case "date":
            case "datetime":
            case "datetime2":
                return(typeof(DateTime));

            case "binary":
            case "varbinary":
                return(typeof(byte[]));

            case "smallint":
                return(typeof(short));

            case "tinyint":
                return(typeof(byte));

            default:
                GenerateExceptionHelper.ThrowUnknownMapType(dbType);
                return(typeof(void));
            }
        }
Exemplo n.º 4
0
        public string MapClrToDb(Type clrType)
        {
            if (clrType.IsGenericType && clrType.GetGenericTypeDefinition() == typeof(Nullable <>))
            {
                clrType = Nullable.GetUnderlyingType(clrType);
            }

            if (clrType.IsEnum)
            {
                return(" integer ");
            }

            switch (Type.GetTypeCode(clrType))
            {
            case TypeCode.String:
            case TypeCode.Char:
                return(" varchar2");

            case TypeCode.Int16:
            case TypeCode.UInt16:
            case TypeCode.Int32:
            case TypeCode.UInt32:
                return(" integer ");

            case TypeCode.Int64:
            case TypeCode.UInt64:
            case TypeCode.Decimal:
            case TypeCode.Single:
            case TypeCode.Double:
                return(" decimal ");

            case TypeCode.DateTime:
                return(" date ");

            case TypeCode.Boolean:
                return(" integer ");

            default:
                if (clrType == typeof(Guid))
                {
                    return(" varchar2(64) ");
                }
                else if (clrType == typeof(byte[]))
                {
                    return(" BLOB ");
                }
                else
                {
                    GenerateExceptionHelper.ThrowUnknownMapType(clrType);
                    return(string.Empty);
                }
            }
        }
Exemplo n.º 5
0
        public Type MapDbToClr(string dbType)
        {
            switch (dbType)
            {
            case "130":
            case "202":
                return(typeof(string));

            case "128":
                return(typeof(byte[]));

            case "20":
                return(typeof(long));

            case "3":
                return(typeof(int));

            case "11":
                return(typeof(bool));

            case "6":
            case "14":
            case "131":
                return(typeof(decimal));

            case "7":
            case "133":
            case "134":
                return(typeof(DateTime));

            case "72":
                return(typeof(Guid));

            case "2":
                return(typeof(short));

            case "4":
                return(typeof(float));

            case "16":
                return(typeof(byte));

            default:
                GenerateExceptionHelper.ThrowUnknownMapType(dbType);
                return(typeof(void));
            }
        }