学用MVC4+EF+Razor做网站:钢铁网电子交易平台(二)
对于文章模块:
文章类别Class类:
using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; namespace MvcGangTie.Models { public class Class { [Key] public int ClassId { get; set; } [Required(ErrorMessage = "不能为空")] [MaxLength(50)] [DisplayName("类别")] public string ClassName { get; set; } [MaxLength(20)] [Required(ErrorMessage = "不能为空")] [DisplayName("对应动作")] public string ActionName { get; set; } } }
Article类:
using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Web.Mvc; using System.ComponentModel.DataAnnotations.Schema; namespace MvcGangTie.Models { public class Article { [Key] public int Id { get; set; } public Guid UserId { get; set; } public int ClassId { get; set; } [MaxLength(50)] [Required(ErrorMessage = "不能为空")] [DisplayName("标题:")] public string Title { get; set; } [Column(TypeName = "ntext")] [MaxLength] [Required(ErrorMessage = "不能为空")] [DisplayName("内容:")] [UIHint("Kingdeditor")] [AllowHtml] public string Content { get; set; } [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd}")] public DateTime CreateDate { get; set; } public virtual Class Class { get; set; } public virtual User User { get; set; } } }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。