Loading

adding validation annotators to model classes 在linq to EntityFrame的Model中添加前台验证validation annotators

The same solution can be applied for LINQ to SQL. The snippet the article shows for using the MetadataType will use perfectly well with LINQ to SQL generated classes:

[MetadataType(typeof(MovieMetaData))]
public partial class Movie
{
}

public class MovieMetaData
{
    [Required]
    public object Title { get; set; }

    [Required]
    [StringLength(5)]
    public object Director { get; set; }


    [DisplayName("Date Released")]
    [Required]
    public object DateReleased { get; set; }
}

 

posted @ 2014-11-14 14:33  Dhoopu  阅读(265)  评论(0编辑  收藏  举报