Entity Framework를 처음 사용하고 ASP.Net MVC 4 응용 프로그램에서이 작업을 수행하는 방법을 이해하려고합니다.Entity Framework에서 도메인 클래스에 여러 개체를 데이터베이스에 추가하지 않음
고객 개체 (고객 정보)와 약속의 DateTime이 포함 된 Appointment 개체가 있습니다. 고객 개체를 올바르게 저장하는 방법을 파악할 수 없습니다.
내가 지금하고있는 일을보고 나는 고객 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;
}
}
Customer.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;
}
}
더 많은 코드를 게시하십시오. 여기 고객은 수업입니다. 그것을 정의해야합니다. – Kalyan
어떤 코드를보고 싶습니까? AppointmentService, 저장소 (DbContext), 컨트롤러, 모델이 있습니다. 그것 모두를 게시하는 것이 많이 있습니까? 그것이 필요한 경우 할 수 있습니다. – devfunkd
Customer Class를 정의 했습니까? – Kalyan