Add explicit decimal data types

Issue #768
This commit is contained in:
Arthur Vickers 2017-04-13 11:21:23 -07:00
parent c9a8cfce04
commit aaea92906f
3 changed files with 8 additions and 1 deletions

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Mvc.ModelBinding;
namespace MusicStore.Models namespace MusicStore.Models
@ -22,6 +23,7 @@ namespace MusicStore.Models
[Range(0.01, 100.00)] [Range(0.01, 100.00)]
[DataType(DataType.Currency)] [DataType(DataType.Currency)]
[Column(TypeName = "decimal(18,2)")]
public decimal Price { get; set; } public decimal Price { get; set; }
[Display(Name = "Album Art URL")] [Display(Name = "Album Art URL")]

View File

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Mvc.ModelBinding;
namespace MusicStore.Models namespace MusicStore.Models
@ -64,6 +65,7 @@ namespace MusicStore.Models
[BindNever] [BindNever]
[ScaffoldColumn(false)] [ScaffoldColumn(false)]
[Column(TypeName = "decimal(18,2)")]
public decimal Total { get; set; } public decimal Total { get; set; }
[BindNever] [BindNever]

View File

@ -1,4 +1,6 @@
namespace MusicStore.Models using System.ComponentModel.DataAnnotations.Schema;
namespace MusicStore.Models
{ {
public class OrderDetail public class OrderDetail
{ {
@ -10,6 +12,7 @@
public int Quantity { get; set; } public int Quantity { get; set; }
[Column(TypeName = "decimal(18,2)")]
public decimal UnitPrice { get; set; } public decimal UnitPrice { get; set; }
public virtual Album Album { get; set; } public virtual Album Album { get; set; }