示例#1
0
        public static List <string> GetProvincesGroupBy(PersonList persons)
        {
            var result = new List <string>();

            foreach (var item in persons.GroupBy(x => x.Province))
            {
                result.Add(item.Key);
            }
            return(result);
        }
示例#2
0
        public static List <PersonsInProvince> GetProvincesPersons(PersonList persons)
        {
            var result = new List <PersonsInProvince>();

            foreach (var item in persons.GroupBy(x => x.Province))
            {
                var data = new PersonsInProvince
                {
                    ProvinceName = item.Key,
                    Amount       = item.Count()
                };
                result.Add(data);
            }
            return(result);
        }