1

I am using LinQPad4 for my first time. I have run one of the LinQ query examples in the program,and when I press the Lambda bottom , the program doesn't show the query transformed into Lambda, can anyone help me please?

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();
4

1 回答 1

5

如果是本地查询,则需要插入.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");
于 2013-05-15T05:02:10.097 回答