2

Given:

A list of ids of emails

What I'm doing:

With the BatchBlock group ids and call a Transformblock for each block the simplified transformblock looks like this:

var readBatch = new TransformBlock<List<int>, IEnumerable<Email>>(idList =>
{
    List<Email> mails = new List<Email>();
    foreach(var id in idList)
    {
        mails.Add(new Email(id));
    }
    return mails;
});

Now my next TransformBlock is defined like this

TransformBlock<Email,EMail> filterStep;

What I search: So I need a block which allows me to get a collection as source and returns N-Elements as result. So in this case a block which receives a IEnumerable<Email> and returns Email foreach entryin the enumeration.

So what I search is the opposite of the BatchBlock but i can't find it. Am I overlooking something?

i3arnon
  • 113,022
  • 33
  • 324
  • 344
Boas Enkler
  • 12,264
  • 16
  • 69
  • 143

2 Answers2

7

The block you need is TransformManyBlock. You return an IEnumerable<Email> from the the block's func and it automatically transfers each item individually:

var transformManyBlock = new TransformManyBlock<IEnumerable<Email>, Email>(emails => emails);
i3arnon
  • 113,022
  • 33
  • 324
  • 344
2

TransformManyBlock might be what you are looking for. It takes TInput and returns IEnumerable (1:n).

ba__friend
  • 5,783
  • 2
  • 27
  • 20