Hi Jan, I really appreciate your linq gems! This one pointed me to another solution that, I hope, you and your blog readers could like. It is similar to the value tuple you mentioned:
Using the new keyword to create an anonymous type in a let clause:
var query =
from word in testWords
let entry = new
{
word,
usage = wordUsage.TryGetValue(word, out var u) ? u : 0,
}
orderby entry.usage
select (entry.word, entry.usage);
Or maybe you can directly do:
//[...]
select entry;
to use the whole anonymous object as a result.