我正在尝试使用以下模型创建 mvc 应用程序:(代码很大。我认为您会更容易理解)
public class Job
{
public int JobId { get; set; }
public string Name { get; set; }
public List<Job> GetJobs()
{
List<Job> jobsList = new List<Job>();
jobsList.Add(new Job { JobId = 1, Name = "Operator" });
jobsList.Add(new Job { JobId = 2, Name = "Performer" });
jobsList.Add(new Job { JobId = 3, Name = "Head" });
return jobsList;
}
}
public class Person
{
public virtual int PersonId { get; set; }
public string FullName { get; set; }
public int JobId { get; set; }
public virtual Job Job;
public string Phone { get; set; }
public string Address { get; set; }
public string Passport { get; set; }
[DataType(DataType.MultilineText)]
public string Comments { get; set; }
}
public class PersonPaidTo : Person
{
[Key]
public override int PersonId { get; set; }
public virtual List<Order> Orders { get; set; }
}
public class Head : Person
{
[Key]
public override int PersonId { get; set; }
public Job Job { get; set; }
public Head()
{
Job.Id = 3;
}
}
Person
我在该领域的课堂上有错误Job
:
修饰符“虚拟”对此项目无效