在一个ASPNET MVC应用中添加对Unity的程序集MicrosoftPracticesUnitydll的引用(如果读者不想安装Unity可以通过下载本实例的源代码的方式获取该程序集)然后在Models目录下定义如下一个表示员工信息的Employee类型
public class Employee
{
[Display(Name=ID)]
public string Id { get; private set; }
[Display(Name = 姓名)]
public string Name { get; private set; }
[Display(Name = 性别)]
public string Gender { get; private set; }
[Display(Name = 出生日期)]
[DataType(DataTypeDate)]
public DateTime BirthDate { get; private set; }
[Display(Name = 部门)]
public string Department { get; private set; }
public Employee(string id string name string gender DateTime birthDate
string department)
{
thisId = id;
thisName = name;
thisGender = gender;
thisBirthDate = birthDate;
thisDepartment = department;
}
}
返回目录ASPNET MVC 框架揭秘
编辑推荐
ASP NET开发培训视频教程
Microsoft NET框架程序设计视频教程
Java程序性能优化让你的Java程序更快更稳定
Visual C++音频/视频技术开发与实战
[] []