【发布时间】:2019-11-04 00:50:29
【问题描述】:
我有一个 doctor 和 patient 类型的列表。
我需要一种方法来遍历列表并获取所有已由特定doctor 治疗的患者。
//Appointment objects
Appointment app1= new Appointment(doctor1, patient1);
Appointment app2= new Appointment(doctor2, patient3);
Appointment app3= new Appointment(doctor1, patient2);
Appointment app4= new Appointment(doctor3, patient4);
Appointment app1= new Appointment(zdravnik2, pacient4);
Appointment app1= new Appointment(zdravnik3, pacient2);
Appointment app1 = new Appointment(zdravnik3, pacient5);
Appointment app1 = new Appointment(zdravnik1, pacient6);
Appointment app1 = new Appointment(zdravnik2, pacient4);
Appointment app1 = new Appointment(zdravnik1, pacient4);
//The objects are stored in this list, they are added in the constructor
List<Appointment>AllAppointments=new List<Appointment>();
//Gets all the patients that have been treated by a particular doctor
public List<Patient> HadAppointmentWith(Doctor d)
{
//Dont know how to continue from here on
//var find=AllAppointment.GroupBy(x=>x.Patient)
}
【问题讨论】:
-
这能回答你的问题吗? C# Linq where clause as a variable
-
四个类似的答案,都被否决了,没有任何评论
-
是的有点奇怪
-
我想是因为这个问题太简单了,人们跑得很快就能得到他们想要的分数,而真正值得考虑的问题却被忽略了)))
-
是的,刚刚注意到,不是我