我是實體框架的新手,並試圖瞭解如何在ASP.Net MVC 4應用程序中執行此操作。實體框架不在域類中添加多個對象到數據庫
我有一個約會對象,其中包含一個客戶對象(客戶信息)和約會的日期時間。我似乎無法弄清楚如何正確存儲客戶對象。
看着我現在正在做的事情,我在想我應該存儲客戶ID,但我不知道如何在稍後檢索客戶信息(我是否使用Model?Another Domain類「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,Repository(DbContext),Controller,Model。發佈所有內容很重要嗎?我可以,如果這是需要的。 – devfunkd
您是否定義了客戶類? – Kalyan