MVC默认为小数点 后2位

更改设置

在我们现在的MovieDBContext类中重载OnModelCreating方法,代码如下所示。
public class MovieDBContext : DbContext
{
    public DbSet<Movie> Movies { get; set; }
 
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
    modelBuilder.Entity<Movie>().Property(p => p.Price).HasPrecision(18, 2);
    }
}


如果是EF生成的在Mapping中

this.Property(t => t.zbje_D).HasPrecision(15, 6).HasColumnName("zbje_D");

 

关于界面显示还要注意的

 @Html.EditorFor(model => model.tbzje_D)

修改为

@Html.TextBoxFor(model => model.zbje_D)

 

EditorFor默认显示2位的

相关文章:

  • 2021-07-08
  • 2022-12-23
  • 2022-12-23
  • 2021-06-21
  • 2022-01-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-09
  • 2021-06-26
  • 2022-12-23
  • 2021-07-28
  • 2022-01-07
  • 2021-07-29
相关资源
相似解决方案