Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

255
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda