internal object[] GetItemPropertyDistinctValues(DataGridItemPropertyBase dataGridItemProperty) { if (m_queryableSource == null) { return(new object[0]); } IQueryable distinctQueryable = m_queryableSource.GetSubGroupsAndCountsQueryable(dataGridItemProperty.Name, false, ListSortDirection.Ascending); List <object> distinctValuesAndCounts = new List <object>(); try { System.Collections.IEnumerator enumerator = distinctQueryable.GetEnumerator(); while (enumerator.MoveNext()) { QueryableExtensions.IQueryableGroupNameCountPair current = enumerator.Current as QueryableExtensions.IQueryableGroupNameCountPair; if (current != null) { distinctValuesAndCounts.Add(current.GroupName); } } return(distinctValuesAndCounts.ToArray()); } catch { // TimeOut exception on the connection or other. return(new object[0]); } }
internal override ObservableCollection <object> QuerySubCollectionViewGroupList(GroupDescription childGroupBy, int nextLevel, bool nextLevelIsBottom) { string childGroupByPropertyName = DataGridCollectionViewBase.GetPropertyNameFromGroupDescription(childGroupBy); if (String.IsNullOrEmpty(childGroupByPropertyName)) { throw new NotSupportedException("Custom groups are not supported when using a DataGridVirtualizingQueryableCollectionView."); } DataGridVirtualizingCollectionViewBase collectionView = this.GetCollectionView(); bool sortGroupBy = false; ListSortDirection groupByDirection = ListSortDirection.Ascending; foreach (SortDescription sortDescription in collectionView.SortDescriptions) { if (sortDescription.PropertyName == childGroupByPropertyName) { sortGroupBy = true; groupByDirection = sortDescription.Direction; break; } } IQueryable groupsAndCountsQueryable = this.Queryable.GetSubGroupsAndCountsQueryable(childGroupByPropertyName, sortGroupBy, groupByDirection); List <QueryableExtensions.IQueryableGroupNameCountPair> distinctValuesAndCounts = new List <QueryableExtensions.IQueryableGroupNameCountPair>(); try { System.Collections.IEnumerator enumerator = groupsAndCountsQueryable.GetEnumerator(); while (enumerator.MoveNext()) { QueryableExtensions.IQueryableGroupNameCountPair current = enumerator.Current as QueryableExtensions.IQueryableGroupNameCountPair; if (current != null) { distinctValuesAndCounts.Add(current); } } } catch { // TimeOut exception on the connection or other. distinctValuesAndCounts.Clear(); } // If we are not the bottom level, we should have subgroups. // However, if the connection timed out and the catch statement set the coundAndDistinctValues to an empty array, // then we shouldn't add anything. We cannot reset on the spot since we might already be resetting. // Create the collection of sub CollectionViewGroups ObservableCollection <object> subCollectionViewGroupList = new ObservableCollection <object>(); int runningCount = this.StartGlobalIndex; int distinctValuesCount = distinctValuesAndCounts.Count; for (int i = 0; i < distinctValuesCount; i++) { QueryableExtensions.IQueryableGroupNameCountPair queryableGroupNameCountPair = distinctValuesAndCounts[i]; subCollectionViewGroupList.Add( new DataGridVirtualizingQueryableCollectionViewGroup(queryableGroupNameCountPair.GroupName, queryableGroupNameCountPair.Count, runningCount, this, nextLevel, nextLevelIsBottom)); runningCount += queryableGroupNameCountPair.Count; } return(subCollectionViewGroupList); }