Type varbinary sql server attribute with c#

Asked

Viewed 154 times

-1

That column DocumentoPDF until now it was not used by the:

inserir a descrição da imagem aqui
I mean I was always null, however at some point added values and then error occurred in my query linq and the problem is that at the moment I am not using this attribute:

This is the error message:

"já existe um DataReader aberto associado a este command que deve ser fechado primeiro"

inserir a descrição da imagem aqui

The error already occurs even before the execution of the query:

IEnumerable<MinhaEntidade> minhaEntidade = new IEnumerable<MinhaEntidade>()
IEnumerable<MinhaEntidade> _dados = from prg in minhaEntidade.listaDados()                                                                               join servicos in _servicos on prg.IdServico equals servicos.Id into outServicos
join servicos in _servicos on prg.IdServico equals servicos.Id into outServicos
from servicos in outServicos.DefaultIfEmpty()
select new ProcessamentoRegistrosDTO
{
Id = prg.Id,
Nome = prg.Nome,
Campo1= servicos.Campo1,
Campo2= prg.Campo2
};

That is the entity:

public class MinhaEntidadeDTO
    {
        public int Id { get; set; }
        public int IdServico {get; set;}
        public string Nome { get; set; }
        public string SobreNome { get; set; }
        public string DocumentoPDF { get; set; }
    }
  • Enabling MARS in his connectionstring It will probably work, but try to identify where you are opening the connection and running more than one command on it. I don’t understand exactly where the error is occurring by what you published.

  • @George Wurthmann edited the question and added an error image.

  • The root cause of the problem has been identified and the problem has been solved and I will add the solution to the post.

  • 2

    The problem is the tipo of the attribute in the application data model: type string and in the Sql Server database varbinary, although not using this attribute in my queries the error displayed has not much to do with the fact, but I changed the model to byte[] and the error no longer occurs.

1 answer

0

Problem solved after changing the type of data in the model: from string for byte[].

Browser other questions tagged

You are not signed in. Login or sign up in order to post.