0
導聯 - >活動之間有一對多的關係。我的要求是選擇一個導致只有一個最近添加的活動(wrt activities.date_created) 這是我的代碼加入條件Linq查詢asp.net
public List<DOlead> getInactiveLeads(DateTime Start, DateTime End, DOuser user)
{
List<lead> ObjLeads = new List<lead>();
List<DOlead> ObjLead = new List<DOlead>();
//List<activity> actobj = _Context.activities;
company comobj = _Context.companies.Where(x => x.id == user.company_id).FirstOrDefault();
DateTime inactive = DateTime.Today.AddDays(-Convert.ToDouble(comobj.no_activity));
ObjLead = (from le in _Context.leads
join leadstatus in _Context.leads_status on le.lead_status_id equals leadstatus.id
join act in _Context.activities on le.id equals act.lead_id
where le.is_converted == false && le.date_created < inactive && le.date_created>Start && le.date_created<End
select new DOlead
{
id = le.id,
title = le.title,
is_converted = le.is_converted,
street_address = le.street_address,
}).OrderByDescending(x => x.title).ToList();
return ObjLead;
}
但它給出了匹配的數據與重複的線索。 請親引導我?