Ejemplo n.º 1
0
 public virtual string ToQueryString(QueryFormatOptions formatFlags)
 {
     if (RuntimeOnlyType != null)
     {
         return(RuntimeOnlyType.ToString());
     }
     return(SqlDbType.ToString());
 }
Ejemplo n.º 2
0
        //public Type GetClosestRuntimeType()
        //{
        //    if (RuntimeOnlyType != null)
        //    {
        //        return RuntimeOnlyType;
        //    }
        //    return GetClosestRuntimeType(SqlDbType);
        //}

        //protected abstract Type GetClosestRuntimeType(DBType sqlDbType);

        public override int GetHashCode()
        {
            int hashCode = 0;

            if (RuntimeOnlyType != null)
            {
                hashCode = RuntimeOnlyType.GetHashCode();
            }
            else if (ApplicationTypeIndex.HasValue)
            {
                hashCode = ApplicationTypeIndex.Value;
            }
            return((((hashCode ^ SqlDbType.GetHashCode()) ^ (Size.HasValue ? Size.GetValueOrDefault() : 0)) ^ Precision) ^ (Scale << 8));
        }
Ejemplo n.º 3
0
        string IProviderType.ToQueryString(QueryFormatOptions formatOptions)
        {
            if (RuntimeOnlyType != null)
            {
                return(RuntimeOnlyType.ToString());
            }
            var builder = new StringBuilder();

            switch (SqlDbType)
            {
            case MySqlDbType.Int32:
                builder.Append("SIGNED");
                break;

            default:
                builder.Append(SqlDbType.ToString());
                break;
            }
            return(builder.ToString());
        }
Ejemplo n.º 4
0
        public override string ToQueryString(QueryFormatOptions formatFlags)
        {
            if (RuntimeOnlyType != null)
            {
                return(RuntimeOnlyType.ToString());
            }
            var builder = new StringBuilder();

            switch (SqlDbType)
            {
            case FbDbType.VarChar:    //System.Data.SqlDbType.NVarChar:
                builder.Append("VarChar");
                builder.Append("(");
                builder.Append(Size);
                builder.Append(")");
                return(builder.ToString());

            case FbDbType.Guid:
                builder.Append("CHAR(38)");
                return(builder.ToString());

            case FbDbType.Binary:
                builder.Append("BLOB");
                builder.Append("(");
                builder.Append(Size);
                builder.Append(")");
                return(builder.ToString());

            case FbDbType.TimeStamp:
                builder.Append(FbDbType.TimeStamp);
                return(builder.ToString());

            //case System.Data.SqlDbType.DateTimeOffset:
            //    builder.Append(FbDbType.Time);
            //    return builder.ToString();

            case FbDbType.Double:    //System.Data.SqlDbType.Real:
                builder.Append("Double Precision");
                return(builder.ToString());

            case FbDbType.Decimal:    //System.Data.SqlDbType.Decimal:
                builder.Append(FbDbType.Decimal);
                //if (Precision != 0 && Scale != 0)
                //{
                //const int MaxPrecision = 18;
                builder.Append("(");
                //builder.Append(Precision > MaxPrecision ? 18 : Precision);
                builder.Append(Precision);
                //if (Scale != 0)
                //{
                builder.Append(",");
                builder.Append(Scale);
                //}
                builder.Append(")");
                //}
                return(builder.ToString());

            case FbDbType.Char:    //System.Data.SqlDbType.NChar:
                builder.Append("Char");
                builder.Append("(");
                builder.Append(Size);
                builder.Append(")");
                //builder.Append(" CHARACTER SET UNICODE_FSS");
                return(builder.ToString());

            case FbDbType.Text:    //System.Data.SqlDbType.NText:
                builder.Append("BLOB SUB_TYPE TEXT SEGMENT SIZE 4000");
                //builder.Append("VarChar(4000)");
                return(builder.ToString());

                #region MyRegion
                //case FbDbType.SmallInt://System.Data.SqlDbType.TinyInt:
                //    builder.Append(FbDbType.SmallInt);
                //    return builder.ToString();
                //case System.Data.SqlDbType.BigInt:
                //case System.Data.SqlDbType.Bit:
                //case System.Data.SqlDbType.Image:
                //case System.Data.SqlDbType.Int:
                //case System.Data.SqlDbType.Money:
                //case System.Data.SqlDbType.SmallDateTime:
                //case System.Data.SqlDbType.SmallInt:
                //case System.Data.SqlDbType.SmallMoney:
                //case System.Data.SqlDbType.Text:
                //case System.Data.SqlDbType.Timestamp:
                //case System.Data.SqlDbType.Xml:
                //case System.Data.SqlDbType.Udt:
                #endregion
            default:
                builder.Append(SqlDbType.ToString());
                return(builder.ToString());

                #region MyRegion
                //case FbDbType.Binary://System.Data.SqlDbType.Binary:
                //case System.Data.SqlDbType.Char:
                //    //case System.Data.SqlDbType.NChar:
                //    builder.Append(this.sqlDbType);
                //    if ((formatFlags & QueryFormatOptions.SuppressSize) == QueryFormatOptions.None)
                //    {
                //        builder.Append("(");
                //        builder.Append(this.size);
                //        builder.Append(")");
                //    }
                //    return builder.ToString();


                //case System.Data.SqlDbType.Float:
                //    builder.Append(this.sqlDbType);
                //    if (this.precision != 0)
                //    {
                //        builder.Append("(");
                //        builder.Append(this.precision);
                //        if (this.scale != 0)
                //        {
                //            builder.Append(",");
                //            builder.Append(this.scale);
                //        }
                //        builder.Append(")");
                //    }
                //    return builder.ToString();

                //case System.Data.SqlDbType.VarChar:
                //    builder.Append(this.sqlDbType);
                //    if (!size.HasValue || ((size == 0) || ((formatFlags & QueryFormatOptions.SuppressSize) != QueryFormatOptions.None)))
                //    {
                //        return builder.ToString();
                //    }
                //    builder.Append("(");
                //    if (this.size != -1)
                //        builder.Append(this.size);
                //    else
                //        builder.Append("MAX");

                //    builder.Append(")");
                //    return builder.ToString();

                //case System.Data.SqlDbType.Variant:
                //    builder.Append("sql_variant");
                //    return builder.ToString();

                //default:
                //    return builder.ToString();
                #endregion
            }
        }
Ejemplo n.º 5
0
        public override string ToQueryString(QueryFormatOptions formatFlags)
        {
            if (RuntimeOnlyType != null)
            {
                return(RuntimeOnlyType.ToString());
            }
            var builder = new StringBuilder();

            string typeName;
            var    size    = Size;
            var    unicode = false;

            switch (SqlDbType)
            {
            case MySqlDbType.Date:
            case MySqlDbType.DateTime:
            case MySqlDbType.Time:
                typeName = SqlDbType.ToString();
                size     = 0;
                break;

            case MySqlDbType.Bit:
                typeName = "BIT";
                break;

            case MySqlDbType.Byte:
                typeName = "TINYINT";
                break;

            case MySqlDbType.Double:
                typeName = "DOUBLE";
                break;

            case MySqlDbType.UByte:
                typeName = "TINYINT";
                break;

            case MySqlDbType.Int16:
                typeName = "SMALLINT";
                break;

            case MySqlDbType.Int24:
                typeName = "MEDIUMINT";
                break;

            case MySqlDbType.UInt24:
                typeName = "MEDIUMINT";
                break;

            case MySqlDbType.Int32:
                typeName = "INT";
                break;

            case MySqlDbType.UInt32:
                typeName = "INT";
                break;

            case MySqlDbType.Int64:
                typeName = "BIGINT";
                break;

            case MySqlDbType.UInt64:
                typeName = "BIGINT";
                break;

            case MySqlDbType.Float:
                typeName = "FLOAT";
                break;

            case MySqlDbType.VarChar:
                typeName = "VARCHAR";
                break;

            default:
                typeName = SqlDbType.ToString();
                break;
                //throw SqlClient.Error.InvalidProviderType(SqlDbType);
            }
            builder.Append(typeName);
            if (size > 0 && formatFlags != QueryFormatOptions.SuppressSize)
            {
                builder.Append("(");
                builder.Append(Size);
                builder.Append(")");
            }
            if (Unsigned)
            {
                builder.Append("UNSIGNED");
            }
            return(builder.ToString());
        }