Exemple #1
0
        public virtual IEnumerable <DataTable> Shard(IIdentifyShard identifier)
        {
            if (null == identifier)
            {
                throw new ArgumentNullException("identifier");
            }

            DataTable table   = null;
            string    current = null;

            foreach (var entry in this)
            {
                var id = identifier.IdentifyShard(entry);
                if (null == table)
                {
                    table = NewDataTable(id, entry);
                }

                if (id != current)
                {
                    current = id;
                    if (0 != table.Rows.Count)
                    {
                        yield return(table);
                    }

                    table = NewDataTable(id, entry);
                }

                var row = NewDataRow(table, entry);

                table.Rows.Add(row);
            }

            if (null == table)
            {
                yield break;
            }

            if (0 != table.Rows.Count)
            {
                yield return(table);
            }
        }
Exemple #2
0
        public virtual IEnumerable <DataShard> Shard(IIdentifyShard identifier)
        {
            if (null == identifier)
            {
                throw new ArgumentNullException("identifier");
            }

            DataShard shard   = null;
            string    current = null;

            foreach (var entry in this)
            {
                var id = identifier.IdentifyShard(entry);
                if (null == shard)
                {
                    shard = new DataShard(id);
                }

                if (id != current)
                {
                    current = id;
                    if (0 != shard.Entries.Count)
                    {
                        yield return(shard);
                    }

                    shard = new DataShard(id);
                }

                shard.Entries.Add(entry);
            }

            if (null == shard)
            {
                yield break;
            }

            if (0 != shard.Entries.Count)
            {
                yield return(shard);
            }
        }