示例#1
0
        public object GetValue(int i)
        {
            var columnType = GetFieldType(i);
            var typeCode   = Type.GetTypeCode(columnType);

            if (columnType == typeof(byte[]))
            {
                IntPtr blob   = UnsafeNativeMethods.ColumnBlob(NativeCommand, i);
                int    size   = UnsafeNativeMethods.ColumnBytes(NativeCommand, i);
                var    buffer = new byte[size];
                Marshal.Copy(blob, buffer, 0, size);
                return(buffer);
            }

            switch (typeCode)
            {
            case TypeCode.DBNull:
                return(null);

            case TypeCode.Int64:
                return(GetInt64(i));

            case TypeCode.Double:
                return(GetDouble(i));

            case TypeCode.String:
                return(GetString(i));

            default:
                throw new SqliteException("Unhandled type code " + typeCode);
            }
        }
示例#2
0
        public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length)
        {
            if (fieldOffset != 0)
            {
                throw new SqliteException("Field offset not yet supported");
            }

            IntPtr blob = UnsafeNativeMethods.ColumnBlob(NativeCommand, i);
            int    size = UnsafeNativeMethods.ColumnBytes(NativeCommand, i);

            length = Math.Min(size, length);
            Marshal.Copy(blob, buffer, bufferoffset, length);
            return(length);
        }