示例#1
0
 public override Type GetFieldType(int i)
 {
     if ((i >= this.VisibleFieldCount) && (this._keyInfo != null))
     {
         return(this._keyInfo.GetFieldType(i - this.VisibleFieldCount));
     }
     return(SQLiteConvert.SQLiteTypeToType(this.GetSQLiteType(i)));
 }
        /// <summary>
        /// Returns the .NET type of a given column
        /// </summary>
        /// <param name="i">The index of the column to retrieve</param>
        /// <returns>Type</returns>
        public override Type GetFieldType(int i)
        {
            if (i >= VisibleFieldCount && _keyInfo != null)
            {
                return(_keyInfo.GetFieldType(i - VisibleFieldCount));
            }

            return(SQLiteConvert.SQLiteTypeToType(GetSQLiteType(i)));
        }
        /// <summary>
        /// Retrieves the name of the back-end datatype of the column
        /// </summary>
        /// <param name="i">The index of the column to retrieve</param>
        /// <returns>string</returns>
        public override string GetDataTypeName(int i)
        {
            CheckClosed();
            SQLiteType typ = GetSQLiteType(i);

            if (typ.Type == DbType.Object)
            {
                return(SQLiteConvert.SQLiteTypeToType(typ).Name);
            }

            return(_activeStatement._sql.ColumnType(_activeStatement, i, out typ.Affinity));
        }
示例#4
0
        public override string GetDataTypeName(int i)
        {
            if ((i >= this.VisibleFieldCount) && (this._keyInfo != null))
            {
                return(this._keyInfo.GetDataTypeName(i - this.VisibleFieldCount));
            }
            SQLiteType sQLiteType = this.GetSQLiteType(i);

            if (sQLiteType.Type == DbType.Object)
            {
                return(SQLiteConvert.SQLiteTypeToType(sQLiteType).Name);
            }
            return(this._activeStatement._sql.ColumnType(this._activeStatement, i, out sQLiteType.Affinity));
        }
示例#5
0
文件: SQLite3.cs 项目: bdcliang/BD
        internal override object GetValue(SQLiteStatement stmt, int index, SQLiteType typ)
        {
            if (this.IsNull(stmt, index))
            {
                return(DBNull.Value);
            }
            TypeAffinity affinity = typ.Affinity;
            Type         type     = null;

            if (typ.Type != DbType.Object)
            {
                type     = SQLiteConvert.SQLiteTypeToType(typ);
                affinity = SQLiteConvert.TypeToAffinity(type);
            }
            switch (affinity)
            {
            case TypeAffinity.Int64:
                if (type != null)
                {
                    return(Convert.ChangeType(this.GetInt64(stmt, index), type, null));
                }
                return(this.GetInt64(stmt, index));

            case TypeAffinity.Double:
                if (type != null)
                {
                    return(Convert.ChangeType(this.GetDouble(stmt, index), type, null));
                }
                return(this.GetDouble(stmt, index));

            case TypeAffinity.Blob:
                if ((typ.Type != DbType.Guid) || (typ.Affinity != TypeAffinity.Text))
                {
                    int    nLength = (int)this.GetBytes(stmt, index, 0, null, 0, 0);
                    byte[] bDest   = new byte[nLength];
                    this.GetBytes(stmt, index, 0, bDest, 0, nLength);
                    if ((typ.Type == DbType.Guid) && (nLength == 0x10))
                    {
                        return(new Guid(bDest));
                    }
                    return(bDest);
                }
                return(new Guid(this.GetText(stmt, index)));

            case TypeAffinity.DateTime:
                return(this.GetDateTime(stmt, index));
            }
            return(this.GetText(stmt, index));
        }
        /// <summary>
        /// Retrieves the name of the back-end datatype of the column
        /// </summary>
        /// <param name="i">The index of the column to retrieve</param>
        /// <returns>string</returns>
        public override string GetDataTypeName(int i)
        {
            if (i >= VisibleFieldCount && _keyInfo != null)
            {
                return(_keyInfo.GetDataTypeName(i - VisibleFieldCount));
            }

            SQLiteType typ = GetSQLiteType(i);

            if (typ.Type == DbType.Object)
            {
                return(SQLiteConvert.SQLiteTypeToType(typ).Name);
            }
            return(_activeStatement._sql.ColumnType(_activeStatement, i, out typ.Affinity));
        }
示例#7
0
        /// <summary>
        /// Helper function to retrieve a column of data from an active statement.
        /// </summary>
        /// <param name="stmt">The statement being step()'d through</param>
        /// <param name="index">The column index to retrieve</param>
        /// <param name="typ">The type of data contained in the column.  If Uninitialized, this function will retrieve the datatype information.</param>
        /// <returns>Returns the data in the column</returns>
        internal virtual object   GetValue(SQLiteStatement stmt, int index, ref SQLiteType typ)
        {
            if (typ.Affinity == 0)
            {
                typ = SQLiteConvert.ColumnToType(stmt, index);
            }
            if (IsNull(stmt, index))
            {
                return(DBNull.Value);
            }

            Type t = SQLiteConvert.SQLiteTypeToType(typ);

            switch (TypeToAffinity(t))
            {
            case TypeAffinity.Blob:
                if (typ.Type == DbType.Guid && typ.Affinity == TypeAffinity.Text)
                {
                    return(new Guid(GetText(stmt, index)));
                }

                int    n = (int)GetBytes(stmt, index, 0, null, 0, 0);
                byte[] b = new byte[n];
                GetBytes(stmt, index, 0, b, 0, n);

                if (typ.Type == DbType.Guid && n == 16)
                {
                    return(new Guid(b));
                }

                return(b);

            case TypeAffinity.DateTime:
                return(GetDateTime(stmt, index));

            case TypeAffinity.Double:
                return(Convert.ChangeType(GetDouble(stmt, index), t, null));

            case TypeAffinity.Int64:
                return(Convert.ChangeType(GetInt64(stmt, index), t, null));

            default:
                return(GetText(stmt, index));
            }
        }
 /// <summary>
 /// Returns the .NET type of a given column
 /// </summary>
 /// <param name="i">The index of the column to retrieve</param>
 /// <returns>Type</returns>
 public override Type GetFieldType(int i)
 {
     CheckClosed();
     return(SQLiteConvert.SQLiteTypeToType(GetSQLiteType(i)));
 }
示例#9
0
        /// <summary>
        /// Helper function to retrieve a column of data from an active statement.
        /// </summary>
        /// <param name="stmt">The statement being step()'d through</param>
        /// <param name="index">The column index to retrieve</param>
        /// <param name="typ">The type of data contained in the column.  If Uninitialized, this function will retrieve the datatype information.</param>
        /// <returns>Returns the data in the column</returns>
        internal override object GetValue(SQLiteStatement stmt, int index, SQLiteType typ)
        {
            if (IsNull(stmt, index))
            {
                return(DBNull.Value);
            }
            TypeAffinity aff = typ.Affinity;
            Type         t   = null;

            if (typ.Type != DbType.Object)
            {
                t   = SQLiteConvert.SQLiteTypeToType(typ);
                aff = TypeToAffinity(t);
            }

            switch (aff)
            {
            case TypeAffinity.Blob:
                if (typ.Type == DbType.Guid && typ.Affinity == TypeAffinity.Text)
                {
                    return(new Guid(GetText(stmt, index)));
                }

                int    n = (int)GetBytes(stmt, index, 0, null, 0, 0);
                byte[] b = new byte[n];
                GetBytes(stmt, index, 0, b, 0, n);

                if (typ.Type == DbType.Guid && n == 16)
                {
                    return(new Guid(b));
                }

                return(b);

            case TypeAffinity.DateTime:
                return(GetDateTime(stmt, index));

            case TypeAffinity.Double:
                if (t == null)
                {
                    return(GetDouble(stmt, index));
                }
                else
                {
                    return(Convert.ChangeType(GetDouble(stmt, index), t, null));
                }

            case TypeAffinity.Int64:
                if (t == null)
                {
                    return(GetInt64(stmt, index));
                }
                else
                {
                    return(Convert.ChangeType(GetInt64(stmt, index), t, null));
                }

            default:
                return(GetText(stmt, index));
            }
        }