Real type fields in bank with problems loading Model

Asked

Viewed 40 times

0

About 3 or 4 months ago I had this same problem, which after I remade all my Model, solved it. And now it’s back to the same problem. Before it was with the float and now with the guy Royal. In my Model is decimal and gives the error. I have changed to Single, Decimal, decimal, float, double and continues. Using Sql Server 2012.

The 'Custodiario' Property on 'Release' could not be set to a 'System.Single' value. You must set this Property to a non-null value of type 'System.Decimal'.

A Model

[Table("LIBERACAO")]
    public class Liberacao
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [DefaultValue(0)]
        [Column("ID_LIBERACAO")]
        public int IdLiberacao { get; set; }
        [Column("FLAG_LIBERACAO")]
        public byte FlagLiberacao { get; set; }
        [DefaultValue(0)]
        [Column("ID_ORCAMENTO")]
        public double IdOrcamento { get; set; }
        [Column("ID_VENDEDOR")]
        public int IdVendedor { get; set; }
        [Column("VENDEDOR")]
        public string Vendedor { get; set; }
        [Column("ID_FILIAL")]
        public int IdFilial { get; set; }
        [Column("FILIAL")]
        public string Filial { get; set; }
        [DefaultValue(0)]
        [Column("DATALIB")]
        public double DataLib { get; set; }
        [DefaultValue(0)]
        [Column("HORALIB")]
        public double HoraLib { get; set; }
        [Column("ID_CLIENTE")]
        public int IdCliente { get; set; }
        [Column("CLIENTE")]
        public string Cliente { get; set; }
        [Column("TIPO_VENDA")]
        public string TipoVenda { get; set; }
        [DefaultValue(0)]
        [Column("JUROS")]
        public double Juros { get; set; }
        [DefaultValue(0)]
        [Column("DESCONTO")]
        public double Desconto { get; set; }
        [DefaultValue(0)]
        [Column("VENCIMENTO")]
        public double Vencimento { get; set; }
        [DefaultValue(0)]
        [Column("ACRESCIMO")]
        public double Acrescimo { get; set; }
        [DefaultValue(0)]
        [Column("ENTRADA")]
        public double Entrada { get; set; }
        [DefaultValue(0)]
        [Column("PRAZO")]
        public double Prazo { get; set; }
        [DefaultValue(0)]
        [Column("TOTAL_LIQUIDO")]
        public double TotalLiquido { get; set; }
        [DefaultValue(0)]
        [Column("MIN_TOTAL")]
        public double MinTotal { get; set; }
        [Column("USUARIO")]
        public string Usuario { get; set; }
        [DefaultValue(0)]
        [Column("CUSTODIARIO")]
        public decimal CustoDiario { get; set; }
        [DefaultValue(0)]
        [Column("MAX_COMI")]
        public decimal MaxComi { get; set; }
        [DefaultValue(0)]
        [Column("VALOR_COMI")]
        public decimal ValorComi { get; set; }
        [DefaultValue(0)]
        [Column("NOVA_COMI")]
        public decimal NovaComi { get; set; }
        [Column("MENSSAGEM")]
        public string Mensagem { get; set; }
        [Column("Menssagem_RET")]
        public string MensagemRet { get; set; }
        [DefaultValue(0)]
        [Column("DataRetorno")]
        public Single DataRetorno { get; set; }
        [DefaultValue(0)]
        [Column("HoraRetorno")]
        public Single HoraRetorno { get; set; }
        [DefaultValue(0)]
        [Column("TempoProcesso")]
        public Single TempoPrecesso { get; set; }
        [Column("Tipo")]
        public int Tipo { get; set; }
        [Column("PROGRAMA")]
        public string Programa { get; set; }
        [Column("NOME_PC")]
        public string NomePc { get; set; }
        [Column("NOME_PROCEDURE")]
        public string NomeProcedure { get; set; }
        [Column("Perc_Juros_Total")]
        public string PercJurosTotal { get; set; }
        [Column("FLAG_CULTURAVENCIDA")]
        public byte FlagCulturaVencida { get; set; }
        [Column("CULTURA")]
        public string Cultura { get; set; }
        [Column("CULTURA_VCTO")]
        public int CulturaVcto { get; set; }
        [Column("FLAG_PRORROGADO")]
        public byte FlagProrrogado { get; set; }
        [DefaultValue(0)]
        [Column("VALOR_PRORROGADO")]
        public Single ValorProrrogado { get; set; }
        [Column("DIAS_ATRASO")]
        public int DiasAtrazo { get; set; }
        [Column("ID_VENDEDOR2")]
        public int IdVendedor2 { get; set; }
        [Column("VENDEDOR2")]
        public string Vendedor2 { get; set; }
        [DefaultValue(0)]
        [Column("COMISSAO_VEND2")]
        public Single ComissaoVend2 { get; set; }
        [Column("FLAG_COTACAO")]
        public byte FlagCotacao { get; set; }
        [Column("TipoVenda")]
        public string TipoVenda1 { get; set; }
        [Column("Flag_Receber_Atrasado")]
        public byte FlagReceberAtrazado { get; set; }
        [Column("Autorizou_Receber_Atrasado")]
        public string AutorizouReceberAtrazado { get; set; }

the method in service

[Route("{id}/{value}")]
        public void AtualizaLiberacao(int id, string value)
        {
            try
            {
                var lista = contexto.Liberacoes
                            .Where(l => l.IdOrcamento == id)
                            .ToList();

                lista.ForEach(f =>
                {
                    f.FlagLiberacao = 1;
                    f.AutorizouReceberAtrazado = value;
                });

                contexto.SaveChanges();
            }
            catch(Exception ex)
            {

            }
        }

EDIT1

My context

public class AutorizadorContext : DbContext
    {
        public AutorizadorContext()
            : base("VLINK")
        {
            Database.SetInitializer<AutorizadorContext>(null);
        }
        public DbSet<Liberacao> Liberacoes { get; set; }
        public DbSet<ItensLib> ItensLibs { get; set; }
        public DbSet<TabelaLiberacao> TabelaLiberacoes { get; set; }
    }

1 answer

1

  • Hi Carlos, as I said in the post I did it. See that in my Model I put Single. Including in Model I commented all fields REAL and keeps making the same mistake.

  • You could post your context too?

  • When you change the type of Decimal to Single, you still have the same error?

  • Yes, any configuration the error persists. I had this problem and it was well discussed here. Then I remade my Model, based on the link passed by you, I had seen it before. It was working, so much so that it continues to work on the site, this error is happening here on localhost. Try everything on localhost and then go up. The site is running. I just went to add another service and nothing else and I haven’t even tried the new service. This service has already worked. The user asked for a change, but not service itself, but put a popup and call the service from there. I just changed the location of the call, but the service continues.

  • It’s making mistakes now in almost every field here. Okay.

  • Dude, I recommend you redo the mapping.

  • So I did several clean and recompile and rebooted the VS a few times and suddenly it started working again. I had commented some fields and uncommented and continued to work. I do not know what really happened, but if I get stuck again, put again. Thanks!!

  • All right, man. If you need help, we’re in charge. Hug.

Show 3 more comments

Browser other questions tagged

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