Using the C# compilers query comprehension features, you can write code like:
var names = new string[] { "Dog", "Cat", "Giraffe", "Monkey", "Tortoise" };
var result =
from animalName in names
let nameLength = animalName.Length
where nameLength > 3
orderby nameLength
select animalName;
In the query expression above, the let
keyword allows a value to be passed forward to the where and orderby operations without duplicate calls to animalName.Length
.
What is the equivalent set of LINQ extension method calls that achieves what the "let" keyword does here?