示例#1
0
        public static object SqlDbTypeToVariable(SqlDbType dbType, Variable var)
        {
            switch (dbType)
            {
            case SqlDbType.SmallInt:
            case SqlDbType.Int:
            case SqlDbType.BigInt: return(var.AsInt());

            case SqlDbType.NChar:
            case SqlDbType.NText:
            case SqlDbType.NVarChar: return(var.AsString());

            case SqlDbType.Real:
            case SqlDbType.Decimal:
            case SqlDbType.SmallMoney:
            case SqlDbType.Money:
            case SqlDbType.Float: return(var.AsDouble());

            case SqlDbType.Binary:
            case SqlDbType.Bit: return(var.AsBool());

            case SqlDbType.SmallDateTime:
            case SqlDbType.Date:
            case SqlDbType.Time:
            case SqlDbType.DateTime: return(var.AsDateTime());
            }
            return(var.AsString());
        }
示例#2
0
        public static object SqlDbTypeToType(DbType dbType, Variable var)
        {
            switch (dbType)
            {
            case DbType.Int16:
            case DbType.Int32:
            case DbType.Int64:    return(var.AsInt());

            case DbType.Double:
            case DbType.Single:   return(var.AsDouble());

            case DbType.String:   return(var.AsString());

            case DbType.Byte:
            case DbType.Boolean:  return(var.AsBool());

            case DbType.DateTime: return(var.AsDateTime());
            }
            return(var.AsString());
        }