FundraisingMenu.SearchServices.FundraisingMenuSearchServices.ExpandByPackage C# (CSharp) Method

ExpandByPackage() private method

Duplicate records by package entry. This ensures we will see one project entry per package relationship and that every package is displayed on the front end.
private ExpandByPackage ( List list ) : List
list List
return List
        private List<FundraisingMenuResult> ExpandByPackage(List<FundraisingMenuResult> list)
        {
            // Map the input list to a list of lists, each of which
            // contains a single association between a FundraisingMenuResult
            // and a singleton ProjectPackageDto list. Once the mapping is done,
            // we flatten the nested list back into a single list. The result
            // of this operation is a single list of FundraisingMenuResults
            // that has been expanded to include extra entries, with one
            // entry per project-package relationship.
            return list.Select(delegate(FundraisingMenuResult i)
            {
                return i.ProjectPackage.Select(delegate(ProjectPackageDto p)
                {
                    FundraisingMenuResult result = new FundraisingMenuResult(i);
                    result.ProjectPackage = new List<ProjectPackageDto>() { p };
                    return result;
                });
            }).SelectMany(i => i).ToList();
        }