zzzprojects / GraphDiff

GraphDiff is a library that allows the automatic update of a detached graph using Entity Framework code first.
https://entityframework-graphdiff.net/overview
MIT License
333 stars 101 forks source link

No respects the decimal values #129

Closed robertocorona closed 9 years ago

robertocorona commented 9 years ago

I have this example

public class Concept { public Guid IdConcept { get; set; } public string Name { get; set; } public decimal Price { get; set; } }

var newConcept = new Concept { IdConcept = Guid.NewGuid(), Name = "new 1", Price = Convert.ToDecimal(0.123456) };

context.UpdateGraph(newConcept);

But when stored in the database the stored decimal value is "0.12" only accepts 2 decimal places The field in the database is defined decimal (18, 6)

This is just an example, I use actually context.UpdateGraph(studentClass, map => map .OwnedCollection(a => a.CoursesCollection)); and collections happens exactly the same. Also this error happens if I just keep a single entity.

josh-dastmalchi commented 9 years ago

This is an EF issue - you need to define your decimal precision as part of the EF model - it defaults to 2.

See: http://stackoverflow.com/questions/3504660/decimal-precision-and-scale-in-ef-code-first

ghost commented 9 years ago

Hi Josh,

thanks for supporting Roberto! :)