What is the implementing class for IGrouping?

后端 未结 4 909
逝去的感伤
逝去的感伤 2020-12-03 10:41

I am trying create a WCF Data Services ServiceOperation that does grouping on the server side and then sends the data down to the client.

When I try to call it (or e

4条回答
  •  悲哀的现实
    2020-12-03 10:52

    Here is probably the most basic and generic implementation of IGrouping. Its constructor takes a key and a set of values.

    public class Grouping : IGrouping
    {
        private readonly TKey key;
        private readonly IEnumerable values;
    
        public Grouping(TKey key, IEnumerable values)
        {
            if (values == null)
                throw new ArgumentNullException("values");
            this.key = key;
            this.values = values;
        }
    
        public TKey Key
        {
            get { return key; }
        }
    
        public IEnumerator GetEnumerator()
        {
            return values.GetEnumerator();
        }
    
        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }
    

提交回复
热议问题