示例#1
0
        void SortSponsors(IEnumerable <Sponsor> sponsors)
        {
            var groups = from sponsor in sponsors
                         orderby sponsor.SponsorLevel?.Rank ?? 9999
                         group sponsor by sponsor.SponsorLevel?.Name ?? "Sponsor"
                         into sponsorGroup
                         select new Grouping <string, Sponsor>(sponsorGroup.Key, sponsorGroup.OrderBy(s => s.Rank));

            SponsorsGrouped.ReplaceRange(groups);
        }
示例#2
0
        void SortSponsors(IEnumerable <Sponsor> sponsors)
        {
            var sponsorsRanked = from sponsor in sponsors
                                 orderby sponsor.Name, sponsor.Rank
            orderby sponsor.SponsorLevel.Rank
            select sponsor;

            Sponsors.ReplaceRange(sponsorsRanked);

            var groups = from sponsor in Sponsors
                         group sponsor by sponsor.SponsorLevel.Name
                         into sponsorGroup
                         select new Grouping <string, Sponsor>(sponsorGroup.Key, sponsorGroup);

            SponsorsGrouped.ReplaceRange(groups);
        }