Real-type fields on the bank with loading problems Model

0

Some 3 or 4 months ago I had this same problem, that after I remapped all my Model, it solved. And now it's back to the same problem. It used to be float and now it's Real . In my Model is decimal and gives the error. I have already changed to Single, Decimal, decimal, float, double and continue. I use Sql Server 2012.

  

The 'CustoDiario' property on 'Liberation' could not be set to   '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 that is in the 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; }
    }
    
asked by anonymous 09.11.2017 / 11:05

1 answer

1

You need to change the type of your Custodial field from decimal to single, if the bank is as real. Here is a link below with the data types in Sql Server and their equivalents in C #.

link

    
09.11.2017 / 11:39