-
-
Save masaeedu/13b1048a5f150766f6c6a7409bf92c30 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var staffDTOs = ctx.Set<Staff>().ToList().Select(s => new StaffDTO(s)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Appointment | |
{ | |
#region Properties | |
public int Id { get; set; } | |
#endregion | |
#region Navigation | |
public virtual Client Client { get; set; } | |
public virtual Staff Staff { get; set; } | |
public virtual Service Service { get; set; } | |
public virtual Timetable Timetable { get; set; } | |
#endregion | |
} | |
public class Staff | |
{ | |
public int Id; | |
public virtual ICollection<Appointment> StaffAppointments { get; set; } | |
} | |
public class AppointmentDTO | |
{ | |
int Id; | |
public AppointmentDTO(Appointment entity) { | |
this.Id = entity.Id; | |
// You can copy out more data later if you want | |
} | |
} | |
public class StaffDTO | |
{ | |
int Id; | |
IReadOnlyCollection<AppointmentDTO> Appointments; | |
public StaffDTO(Staff entity) { | |
this.Id = entity.Id; | |
this.Appointments = entity.Appointments.Select(a => new AppointmentDTO(a)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment