V
V
Victor P.2022-02-18 10:41:12
C++ / C#
Victor P., 2022-02-18 10:41:12

Why does decimal.Parse work like this?

Good afternoon,
I get a number (type in base decimal(38,20)) in type string in c# service

var kk = decimal.Parse("884413000");
// kk == 884413000M // что за M?

Further overflow error on writing to the database of this value

Insertion into the database is carried out through the entity framework

var entity = new VendorsLogEntry();
entity.LastBalanceAmount = 884413000M;
db.VendorsLogEntry.Add(entity);
await db.SaveChangesAsync(); //OverflowException: Переполнение при преобразовании.


This column has type in base decimal(38,20)

AND in context:
modelBuilder.Entity<VendorsLogEntry>()
                .Property(e => e.LastBalanceAmount)
                .HasPrecision(38, 20);

Explain, please, what is wrong? Not such a big number

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor P., 2022-02-18
@Jeer

In general, I came across similar errors when reading data. I'm surprised such a crazy situation exists.
I decided that I changed the field type in the database to money, in the entity it was generated as decimal (19,4) and the error went away

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question