We have a code-first database in our project, with a decimal in one of our models.
We set the decimal precision to (6, 2), which we checked in our mysql database's structure.
The collation of the db is utf8_unicode_ci
.
We saved a value of 4.00
to the database from a view, which was correct. However, now that we try to get the value back from the db, in stead of getting 4.00
or 4.00m
, we get 400M
. The comma is just gone.
All help appreciated.
(But please, don't suggest dividing by 100. That's ugly fixing and you know it.)
EDIT Model:
public class RSU
{
public int Id { get; set; }
public virtual RSUSlot SlotRef { get; set; }
public decimal? Length { get; set; }
}
INSERT code:
using(dbCOntext db = new dbCOntext())
{
db.Add(new RSU{ Length = 4.00m });
db.SaveChanges();
}
GET:
public static CabinetConfig GetCabinet(M4CDbContext db, int id)
{
return db.CabinetConfig
.Include(m => m.RSURef)
.Where(m => m.Id == id)
.FirstOrDefault();
}