我是 Entity Framework 的新手,并试图了解如何在 ASP.Net MVC 4 应用程序中执行此操作。
我有一个约会对象,其中包含一个客户对象(客户信息)和约会的日期时间。我似乎无法弄清楚如何正确存储客户对象。
看我现在做事的方式我想我应该存储客户ID,但我不知道以后如何检索客户信息(我使用模型吗?另一个域类“AppointmentDetails”?我应该使用服务层对象?)
public class Appointment
{
public int Id { get; set; }
public Customer Customer { get; set; }
public DateTime AppointmentDateTime { get; set; }
public Appointment()
{
}
public Appointment(Customer customer, DateTime appointmentDateTime)
{
Customer = customer;
AppointmentDateTime = appointmentDateTime;
}
}
客户.cs
public class Customer
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Address { get; set; }
public string City { get; set; }
public string Province { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
public Customer()
{
}
public Customer(string firstName, string lastName, string address, string city, string province, string phone, string email)
{
FirstName = firstName;
LastName = lastName;
Address = address;
City = city;
Province = province;
Phone = phone;
Email = email;
}
}