什么是BatchBlock的相对块 [英] What is the opposite block of BatchBlock
问题描述
给出:
电子邮件ID列表
我在做什么:
有了BatchBlock组ID并为每个块调用一个Transformblock,简化的transformblock如下所示:
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;
});
现在我的下一个TransformBlock定义如下
Now my next TransformBlock is defined like this
TransformBlock<Email,EMail> filterStep;
我搜索的内容:因此,我需要一个块,该块允许我获取一个集合作为源并返回N个元素作为结果.因此,在这种情况下,一个接收 IEnumerable< Email>
并为枚举中的每个条目返回 Email
的块.
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.
所以我搜索的内容与BatchBlock相反,但我找不到它.我在俯视什么吗?
So what I search is the opposite of the BatchBlock but i can't find it. Am I overlooking something?
推荐答案
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);
这篇关于什么是BatchBlock的相对块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!