/// <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)));
        }
Пример #2
0
        /// <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)
        {
            SQLiteType typ = GetSQLiteType(i);

            if (typ.Type == DbType.Object)
            {
                return(SqliteConvert.SQLiteTypeToType(typ).Name);
            }
            return(_activeStatement._sql.ColumnType(_activeStatement, i, out typ.Affinity));
        }
        /// <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));
        }
Пример #4
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));
            }
        }
Пример #5
0
 /// <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)
 {
     return(SqliteConvert.SQLiteTypeToType(GetSQLiteType(i)));
 }