Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

250
Vistas
Can't cast database type tsvector to String

I'm just getting started with PostgreSQL and am trying to perform a full text search. I've got some records in the table, with a column search of type tsvector. That all works great. However, using Npgsql, I'm trying to execute:

using (var cmd = new NpgsqlCommand())
{
    cmd.CommandText = "SELECT search FROM data";
    cmd.Prepare();
    var reader = cmd.ExecuteReader();
}

But I keep getting an InvalidCastException saying

Can't cast database type tsvector to String

I assume there's something more I need to add for it to correctly convert the types, but documentation for NpgSql seems to be virtually non-existent. Is this just not something that can be done, or should I be doing it differently?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I don't have any knowledge of NpgsqlCommand, but have you tried something like this:

var stringResponse= cmd.ExecuteReader().GetString(0);
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda