(Converting a Dictionary
to ILookup
is not very nice:
How do I convert a Dictionary to a Lookup? )
I want to have an interface for my container class with the following method:
ILookup<Type, Entry> Query ( IEnumerable<QueryClause> query );
Each query clause specifies which and how many (and some more details) of a special kind of Entry should be taken out of the underlying container.
My implementation currently looks something like this:
var result = new Dictionary<Type, List<Entry>>();
foreach(var clause in query)
{
var clauseResult = FulfillClause(clause);
result.Add(clause.Type, clauseResult);
}
return result.ToLookup(); // here it is
Is there any chance this method my return ILookup
directly? Unfortunately it does not support yield return
.