I've created a application in C# with SQL Server 2008 R2 backend. In my DB one of the table contains a column with datatype money
. I'm using Entity Framework (Database First) to access data from the DB. In my EF Model, the money
type attributed is represented as decimal
.
Now when I serialize an object of that entity, that decimal property is represented as having 4 decimal places. I need this to have only 2 decimal places. I'm using JSON.NET
to serialize my objects into JSON.
Here is what I'm getting (see the value of Price
property)
{
ID: 1,
Name: "Product1"
Category:
{
ID: 1,
Name: "Category1"
},
Price: 200.0000
}
Here is what I'm need (see the value of Price
property)
{
ID: 1,
Name: "Product1"
Category:
{
ID: 1,
Name: "Category1"
},
Price: 200.00
}
Is there any settings that I need to provide while serialization? Please give me any hint.