Code equivalent to the 'let' keyword in chained LINQ extension method calls
Solution 1:
Let doesn't have its own operation; it piggy-backs off of Select
. You can see this if you use "reflector" to pull apart an existing dll.
it will be something like:
var result = names
.Select(animalName => new { nameLength = animalName.Length, animalName})
.Where(x=>x.nameLength > 3)
.OrderBy(x=>x.nameLength)
.Select(x=>x.animalName);
Solution 2:
There's a good article here
Essentially let
creates an anonymous tuple. It's equivalent to:
var result = names.Select(
animal => new { animal = animal, nameLength = animal.Length })
.Where(x => x.nameLength > 3)
.OrderBy(y => y.nameLength)
.Select(z => z.animal);