Skip to content

Instantly share code, notes, and snippets.

@masaeedu
Forked from wizzar/cloudSettings
Last active June 9, 2016 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masaeedu/13b1048a5f150766f6c6a7409bf92c30 to your computer and use it in GitHub Desktop.
Save masaeedu/13b1048a5f150766f6c6a7409bf92c30 to your computer and use it in GitHub Desktop.
var staffDTOs = ctx.Set<Staff>().ToList().Select(s => new StaffDTO(s));
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