Ejemplo n.º 1
0
        public static IEnumerable <IGrouping <TKey, TSource> > IndexGroupBy <TKey, TSource>(this CSVDataSet <TSource> csvDataSet, Func <TSource, TKey> keySelector)
        {
            IndexManager <object, Segment> workingIndexManager = new IndexManager <object, Segment>();
            string indexName = "TempGroup";

            var innerEnumerable = csvDataSet.GetTypedEnumerable(1);

            foreach (TSource row in innerEnumerable)
            {
                var     key     = keySelector(row);
                Segment segment = csvDataSet.CurrentSegment;
                workingIndexManager.AddMapForKey(indexName, key, segment);
            }


            IndexTable <object, Segment> indexTable = workingIndexManager.GetMap(indexName);

            foreach (TKey key in indexTable.GetMapKeys())
            {
                var source = csvDataSet.GetIndexedTypedEnumerable(indexName, key, workingIndexManager);
                yield return(new IndexGrouping <TKey, TSource>(key, source));
            }

            workingIndexManager = null;
        }
Ejemplo n.º 2
0
        public List <object> GetKeys(string index)
        {
            IndexTable <object, Segment> table = indexManager.GetMap(index, false);
            var keys = table.GetMapKeys();

            return(keys);
        }