示例#1
0
        /// <summary>
        /// Please refer to the documentation of <see cref="GentleSqlFactory"/> for details.
        /// </summary>
        public override long GetDbType(Type type)
        {
            AsaDbType result = AsaDbType.Integer;

            if (type.Equals(typeof(decimal)))
            {
                result = AsaDbType.Decimal;
            }
            else if (type.Equals(typeof(Int16)))
            {
                result = AsaDbType.SmallInt;
            }
            else if (type.Equals(typeof(Int32)) || type.IsEnum)
            {
                result = AsaDbType.Integer;
            }
            else if (type.Equals(typeof(long)))
            {
                result = AsaDbType.BigInt;
            }
            else if (type.Equals(typeof(double)))
            {
                result = AsaDbType.Double;
            }
            else if (type.Equals(typeof(DateTime)))
            {
                result = AsaDbType.DateTime;
            }
            else if (type.Equals(typeof(bool)))
            {
                result = AsaDbType.Bit;
            }
            else if (type.Equals(typeof(string)))
            {
                result = AsaDbType.Text;
            }
            else if (type.Equals(typeof(Guid)))
            {
                result = AsaDbType.UniqueIdentifierStr;
            }
            else
            {
                result = (AsaDbType)NO_DBTYPE;
                Check.Fail(Error.UnsupportedPropertyType, type.Name, this);
            }
            return((long)result);
        }
示例#2
0
        public override Type GetSystemType(long dbType)
        {
            AsaDbType asaDbType = (AsaDbType)Enum.ToObject(typeof(AsaDbType), dbType);

            switch (asaDbType)
            {
            case AsaDbType.BigInt:
                return(typeof(long));

            case AsaDbType.Binary:
                return(typeof(byte[]));

            case AsaDbType.Bit:
                return(typeof(bool));

            case AsaDbType.Char:
                return(typeof(char));

            case AsaDbType.Date:
            case AsaDbType.DateTime:
                return(typeof(DateTime));

            case AsaDbType.Decimal:
                return(typeof(decimal));

            case AsaDbType.Double:
            case AsaDbType.Float:
                return(typeof(double));

            case AsaDbType.Image:
                return(typeof(byte[]));

            case AsaDbType.Integer:
                return(typeof(int));

            case AsaDbType.LongBinary:
                return(typeof(byte[]));

            case AsaDbType.LongVarchar:
                return(typeof(string));

            case AsaDbType.Money:
                return(typeof(decimal));

            case AsaDbType.Numeric:
                return(typeof(decimal));

            case AsaDbType.OldBit:
                return(typeof(bool));

            case AsaDbType.Real:
                return(typeof(decimal));

            case AsaDbType.SmallDateTime:
                return(typeof(DateTime));

            case AsaDbType.SmallInt:
                return(typeof(int));

            case AsaDbType.SmallMoney:
                return(typeof(decimal));

            case AsaDbType.SysName:
                return(typeof(string));

            case AsaDbType.Text:
                return(typeof(string));

            case AsaDbType.Time:
            case AsaDbType.TimeStamp:
                return(typeof(DateTime));

            case AsaDbType.TinyInt:
                return(typeof(int));

            case AsaDbType.UniqueIdentifier:
            case AsaDbType.UniqueIdentifierStr:
                return(typeof(Guid));

            case AsaDbType.UnsignedBigInt:
                return(typeof(long));

            case AsaDbType.UnsignedInt:
                return(typeof(long));

            case AsaDbType.UnsignedSmallInt:
                return(typeof(long));

            case AsaDbType.VarBinary:
                return(typeof(byte[]));

            case AsaDbType.VarChar:
                return(typeof(string));

            default:
                return(typeof(object));
            }
        }