Using the q开发者_如何学编程uery expression style, the let clause can be easily written. My question is how to use the dot notation style to write a let clause.
Essentially it's a Select
(in most cases) which introduces a transparent identifier - via an anonymous type which encapsulates all the currently specified range variables. For example, this query:
string[] names = { "Jon", "Mark" };
var query = from name in names
let length = name.Length
where length > 3
select name + ": " + length;
is translated into something like this:
var query = names.Select(name => new { name, length = name.Length })
.Where(z => z.length > 3)
.Select(z => z.name + ": " z.length);
精彩评论