/// <include file='docs/MyCatDataReader.xml' path='docs/GetDateTime/*'/>
        public override DateTime GetDateTime(int i)
        {
            IMyCatValue   val = GetFieldValue(i, true);
            MyCatDateTime dt;

            if (val is MyCatDateTime)
            {
                dt = (MyCatDateTime)val;
            }
            else
            {
                // we need to do this because functions like date_add return string
                string s = GetString(i);
                dt = MyCatDateTime.Parse(s);
            }

            dt.TimezoneOffset = driver.timeZoneOffset;
            if (connection.Settings.ConvertZeroDateTime && !dt.IsValidDateTime)
            {
                return(DateTime.MinValue);
            }
            else
            {
                return(dt.GetDateTime());
            }
        }
        private static MyCatSchemaCollection GetDataTypes()
        {
            MyCatSchemaCollection dt = new MyCatSchemaCollection("DataTypes");

            dt.AddColumn("TypeName", typeof(string));
            dt.AddColumn("ProviderDbType", typeof(int));
            dt.AddColumn("ColumnSize", typeof(long));
            dt.AddColumn("CreateFormat", typeof(string));
            dt.AddColumn("CreateParameters", typeof(string));
            dt.AddColumn("DataType", typeof(string));
            dt.AddColumn("IsAutoincrementable", typeof(bool));
            dt.AddColumn("IsBestMatch", typeof(bool));
            dt.AddColumn("IsCaseSensitive", typeof(bool));
            dt.AddColumn("IsFixedLength", typeof(bool));
            dt.AddColumn("IsFixedPrecisionScale", typeof(bool));
            dt.AddColumn("IsLong", typeof(bool));
            dt.AddColumn("IsNullable", typeof(bool));
            dt.AddColumn("IsSearchable", typeof(bool));
            dt.AddColumn("IsSearchableWithLike", typeof(bool));
            dt.AddColumn("IsUnsigned", typeof(bool));
            dt.AddColumn("MaximumScale", typeof(short));
            dt.AddColumn("MinimumScale", typeof(short));
            dt.AddColumn("IsConcurrencyType", typeof(bool));
            dt.AddColumn("IsLiteralSupported", typeof(bool));
            dt.AddColumn("LiteralPrefix", typeof(string));
            dt.AddColumn("LiteralSuffix", typeof(string));
            dt.AddColumn("NativeDataType", typeof(string));

            // have each one of the types contribute to the datatypes collection
            MyCatBit.SetDSInfo(dt);
            MyCatBinary.SetDSInfo(dt);
            MyCatDateTime.SetDSInfo(dt);
            MyCatTimeSpan.SetDSInfo(dt);
            MyCatString.SetDSInfo(dt);
            MyCatDouble.SetDSInfo(dt);
            MyCatSingle.SetDSInfo(dt);
            MyCatByte.SetDSInfo(dt);
            MyCatInt16.SetDSInfo(dt);
            MyCatInt32.SetDSInfo(dt);
            MyCatInt64.SetDSInfo(dt);
            MyCatDecimal.SetDSInfo(dt);
            MyCatUByte.SetDSInfo(dt);
            MyCatUInt16.SetDSInfo(dt);
            MyCatUInt32.SetDSInfo(dt);
            MyCatUInt64.SetDSInfo(dt);

            return(dt);
        }
        /// <summary>
        /// Gets the value of the specified column in its native format.
        /// </summary>
        /// <param name="i"></param>
        /// <returns></returns>
        public override object GetValue(int i)
        {
            if (!isOpen)
            {
                Throw(new Exception("No current query in data reader"));
            }
            if (i >= FieldCount)
            {
                Throw(new IndexOutOfRangeException());
            }

            IMyCatValue val = GetFieldValue(i, false);

            if (val.IsNull)
            {
                return(DBNull.Value);
            }

            // if the column is a date/time, then we return a MyCatDateTime
            // so .ToString() will print '0000-00-00' correctly
            if (val is MyCatDateTime)
            {
                MyCatDateTime dt = (MyCatDateTime)val;
                if (!dt.IsValidDateTime && connection.Settings.ConvertZeroDateTime)
                {
                    return(DateTime.MinValue);
                }
                else if (connection.Settings.AllowZeroDateTime)
                {
                    return(val);
                }
                else
                {
                    return(dt.GetDateTime());
                }
            }

            if (val is MyCatJson)
            {
                return(new JsonObject(val.Value.ToString()));
            }

            return(val.Value);
        }