子集合 初始化
public CrmAppointment GetByItems(Guid uid)
{
var crmappointment = GetByPK(uid);
if (crmappointment != null)
{
crmappointment.Custs = new YDotList<Crm_Appointment_Cust>(new CrmAppointmentCustDal().QueryWhere(x => x.refid == uid));
crmappointment.Users = new YDotList<Crm_Appointment_Oth>(new CrmAppointmentOthDal().QueryWhere(x => x.refid == uid));
}
return crmappointment;
}
获取list 集合
List<CrmAppointment> PublicList = new CrmAppointmentDal().QueryWhere(x => x.IsPublic == true && x.StartTime >= startTime && x.EndTime <= EndTime);
List<CrmAppointment> owner = new CrmAppointmentDal().QueryWhere(x => x.create_byid == create_byid && x.StartTime >= startTime && x.EndTime <= EndTime);
List<Crm_Appointment_Oth> users = new CrmAppointmentOthDal().QueryWhere(x => x.usercode == create_byid).ToList();
List<CrmAppointment> Oth = new List<CrmAppointment>();
foreach (var item in users)
{
CrmAppointment model = new CrmAppointmentDal().QueryWhere(x => x.uid == item.refid && x.StartTime >= startTime && x.EndTime <= EndTime).FirstOrDefault();
if (model != null)
{
Oth.Add(model);
}
}
List<CrmAppointment> master = PublicList.Union(owner).Union(Oth).ToList();
master = master.Where((x, i) => master.FindIndex(z => z.uid == x.uid) == i).ToList();
return master;