I need help in better arranging the code in .NET TPL dataflow. here is the code
var finalBlock = new ActionBlock<Category_KeywordsToMatch>(x =>
{
List<Resume> Resumes = new List<Resume>();
using (var context = new IndepthRecruitDbContext())
{
Resumes = context.Resumes.Include("Candidate").ToList();
}
foreach (var res in Resumes)
{
var keywords = FindKeywords(x.KeywordsToMatch, res);
if (keywords.Count > 0)
{
matchedCandidates_dataflow.Add(new MatchedCandidate
{
Id = res.CandidateId,
Name = res.Candidate.Name,
Url = res.Url,
Uploaded = res.DateUploaded.ToShortDateString(),
MatchedKeywordsList = keywords
});
}
}
});
This is the final block of my chain. Here action block input is Category_KeywordsToMatch which is a class containing Job category and list of keywords to match in a resume. {Category, List< Keywords >}. Inside block I am using foreach loop to enumerate through a List of resumes. Is there any better design using dataflow, like Resumes can be supplied as different input. Final block is the last block for one category. I need to search keywords for multiple categories.