public static ObservableCollection <GroupInfoList> GetPatientsGrouped(int numberOfContacts) { ObservableCollection <GroupInfoList> groups = new ObservableCollection <GroupInfoList>(); var query = from item in GetPatients(numberOfContacts) group item by item.LastName.Substring(0, 1).ToUpper() into g orderby g.Key select new { GroupName = g.Key, Items = g }; foreach (var g in query) { GroupInfoList info = new GroupInfoList(); info.Key = g.GroupName; foreach (var item in g.Items) { info.Add(item); } groups.Add(info); } return(groups); }
public static ObservableCollection <GroupInfoList> GetActivePatientsGrouped(int numberOfActivePatients) { ObservableCollection <GroupInfoList> groups = new ObservableCollection <GroupInfoList>(); var query = from item in getActivePatients(numberOfActivePatients) group item by item.Date into g orderby g.Key select new { GroupName = g.Key, Items = g }; foreach (var g in query) { GroupInfoList info = new GroupInfoList(); info.Key = g.GroupName; foreach (var item in g.Items) { info.Add(item); } groups.Add(info); } return(groups); }