Matching a list to a member of an object (also a list)

Hopefully this isn't too confusing, but I'm beating my head against the wall. I have written what I consider an awful hack, but I'm hoping someone can show me the light.

// get initial list from repeater by selecting the value of checkboxes in a repeater

var checkedServices = rpServices.Items .Cast<RepeaterItem>() .Where(x => ((CheckBox) x.FindControl("CheckBoxService")).Checked) .Select(x => Convert.ToInt16(((CheckBox) x.FindControl("CheckBoxService")).ClientID.Substring(2))).ToList(); 

// get list of plans to look for

var planServices = SmartFlowPlan.GetAll(true) .SelectMany(sfp => SmartFlowPlan.GetServices((short) sfp.Id, true)); var aggregate = planServices .GroupBy(ps => ps.SmartFlowPlanId, ps => ps.ServiceId, (id, svc) => new { PlanId = id, Service = svc.ToList() }); 

What I am trying to do is find the list (Service) in "aggregates" that matches my initial list, exactly, and then get the PlanId for the matching list.

And help greatly appreciated.

by ShittyDeveloper via /r/csharp

Leave a Reply