我第一次使用 LinQPad4。我在程序中运行了一个 LinQ 查询示例,当我按下 Lambda 底部时,程序没有显示转换为 Lambda 的查询,有人可以帮我吗?
var words = from word in "The quick brown fox jumps over the lazy dog".Split()
orderby word.ToUpper()
select word;
var duplicates = from word in words
group word.ToUpper() by word.ToUpper()
into g
where g.Count() > 1
select new { g.Key, Count = g.Count() };
words.Dump();
duplicates.Dump();
Run Code Online (Sandbox Code Playgroud)
如果是本地查询,则需要插入.AsQueryable()查询以生成表达式树。这在内置示例中进行了解释,A Note on AsQueryable
var names = new[] { "Tom", "Dick", "Harry", "Mary", "Jay" }.AsQueryable();
// AsQueryable() doesn't change the result of the query. The effect it has it to populate
// the ? tab below—so you can see how the query translates into lambda (fluent) syntax.
// To illustrate, press F5 to run the following:
(
from n in names
where n.Length > 3
orderby n descending
select n.ToUpper()
)
.Dump ("Click the ? button - notice the translation to fluent syntax");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
509 次 |
| 最近记录: |