有人可以幫我把Linq查詢並告訴我怎麼拉出來的獨特產品名稱如何通過一個屬性值的列表中刪除重複項<>
List<StatePlan> planTypes = (from ppt in context.PlanPlanTypes
join pt in context.PlanTypes on ppt.PlanTypeRowID equals pt.PlanTypeRowID
join ppts in context.PlanPlanTypeStates on ppt.PlanPlanTypeRowID equals ppts.PlanPlanTypeRowID
join p in context.Plans on ppt.PlanRowID equals p.PlanRowID
where ppts.StateCode == stateCode
where p.IsActive == true
select new StatePlan
{
PlanID = p.PlanRowID,
StateCode = stateCode,
Name = p.Name,
Description = p.Description,
Disclaimer = p.Disclaimer,
Sequence = p.DisplaySequence,
//Rates = GetRates(p.PlanRowID),
//Types = GetPlanTypes(p.PlanRowID, stateCode)
}).ToList();
return planTypes;
這個偉大的工作,但是,我確實需要改變s.FirstOrDefault() –
這將做太多:) –
@JonHarding你爲什麼需要這種改變?我希望每個組都至少有一個元素。 – CodesInChaos