【发布时间】:2019-01-10 11:26:12
【问题描述】:
我需要在同一个视图中传递两个模型,但是有些元素具有相同的名称。
我有两个模型Employee 和HolidayRequestForm,我需要在一个视图中使用这两个模型,这将是每个员工的详细信息页面。
这是我的Employee:
public partial class Employee
{
public int EmployeeID { get; set; }
public string FullName { get; set; }
public string EmailID { get; set; }
public string Password { get; set; }
public System.DateTime StartDate { get; set; }
public int RoleID { get; set; }
public int ShiftID { get; set; }
public int AreaID { get; set; }
public int DisciplineID { get; set; }
public int SiteID { get; set; }
public int ALCategory { get; set; }
public Nullable<int> HoursTaken { get; set; }
public Nullable<int> AwardedLeave { get; set; }
public Nullable<int> TotalHoursThisYear { get; set; }
public int HoursCarriedForward { get; set; }
public Nullable<int> EntitlementRemainingThisYear { get; set; }
public string Comments { get; set; }
}
这是我的HolidayRequestForm:
public partial class HolidayRequestForm
{
public int RequestID { get; set; }
public int EmployeeID { get; set; }
public System.DateTime StartDate { get; set; }
public System.DateTime FinishDate { get; set; }
public int HoursTaken { get; set; }
public string Comments { get; set; }
public int YearCreated { get; set; }
public int MonthCreated { get; set; }
public Nullable<int> DayCreated { get; set; }
public Nullable<int> YearOfHoliday { get; set; }
}
我尝试创建一个单独的模型,其中包含要在视图中使用的所有元素,但我不确定如何区分具有相同名称的元素,例如。评论 甚至可以这样做吗?
我想在我的视图中使用这两个模型,因为我想创建一个员工资料页面,他们的信息在顶部显示有关他们的个人资料的信息,然后是他们在表格中使用 holidayrequestform 请求的假期页面底部。
【问题讨论】: