I am using Postgres Database with Entity Framework Core.
In my database, Price table has column price(numeric)
and values like 12345.123456789012345678901234567890 are stored i.e. (high precision)
When I fetch data using LINQ query, everytime I got the error :
"System.OverflowException: Numeric value does not fit in a System.Decimal"
I have found method of using Property.HasColumnType("decimal(20,5)")
for column of database in OnModelCreating()
method of DbContext but its not working. Also, I have seen defining select query in edmx file but Entity Framework Core does not generate edmx file.
So, how can we define precision for numeric data type of Postgres with Entity Framework Core in C#? (Note: Precision can be reduced to at least 5 decimal places)
Decimal not support to high precision so you have Used Double
Other Wise Price Value Convert to Decimal Value
Example:
1.stored value price=1234.12345678901234567890
tabledetails.Select(c =>(decimal) c.value).ToList();
Get Vlaue is 1234.12345678901
2.Other wise The before stored the Price Value using decimal then using below format
store Value
1234.12345678901234567890m
Get Value
1234.12345678901234567890