0

In the original version of this ASP.NET program which is for processing data from Dynamics CRM 365, the QueryExpression Result is transferred to ObservableCollection, then final result in xml format. Now I need to add some count() and group by to the QueryExpression or ObservableCollection.

How can I do it? May be with LINQ?

autopenta
  • 57
  • 5

1 Answers1

0

Yes, ObservableCollection is drived from Collection and Collection implements IEnumerable so you can use linq on it.
Here is an example of using Enumerable.Count() and group by on an ObservableCollection:

var li = new Dictionary<int, string> { [1] = "1", [2] = "2", [3] = "3" };
var observCollection = new ObservableCollection<KeyValuePair<int, string>>(li);
var t = (from p in observCollection
         group p by p.Key into grp
         select grp.Count());
AliJP
  • 668
  • 1
  • 4
  • 16