본문 바로가기

Program/ASP.NET

data class 지정방법

[Display(Name = "Release Date")] 
[DataType(DataType.Date)] 
public DateTime ReleaseDate { get; set; } 

[Range(1, 100)] 
[DataType(DataType.Currency)] 
public decimal Price { get; set; }

[MaxLength(30)]    // 30자 내로 입력

[DisplayFormat(DataFormatString =

"{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)] public DateTime ReleaseDate { get; set; }
public class Movie
{
    public int ID { get; set; }

    [StringLength(60, MinimumLength = 3)]
    public string Title { get; set; }

    [Display(Name = "Release Date"), DataType(DataType.Date)]
    public DateTime ReleaseDate { get; set; }

    [RegularExpression(@"^[A-Z]+[a-zA-Z""'\s-]*$"), Required, StringLength(30)]
    public string Genre { get; set; }

    [Range(1, 100), DataType(DataType.Currency)]
    [Column(TypeName = "decimal(18, 2)")]
    public decimal Price { get; set; }

	// 첫번째는 대문자
    [RegularExpression(@"^[A-Z]+[a-zA-Z0-9""'\s-]*$"), StringLength(5)]
    public string Rating { get; set; }
}