【发布时间】:2011-02-11 00:17:29
【问题描述】:
编辑:我已经完全消灭了我最初的问题重新制定它是更直接的方式。我很抱歉,如果这是对任何礼仪,但我认为这将是更糟糕发布关于同一主题的一个新问题:) STRONG> P>
是否有可能写这个LINQ查询与查询综合通过实现自己的SelectMany或类似的语法: P>
我的想法是这样的: 或者: 非常感谢任何帮助、提示、链接等!var enumerable =
Enumerable.Range(1, 10)
.Aggregate(new SomeAggregation(),
(c, n) =>
{
var l = c.SomeOperation(); // expensive operation
return c.UseIt(l).UseItAgain(l); // the result is needed multiple times
});
var enumerable = from c in new SomeAggregation().AsSeed()
from n in Enumerable.Range(1, 10)
from l in c.SomeOperation()
select c.UseIt(l).UseItAgain(l);
var enumerable = from c in new SomeAggregation().AsSeed()
from n in Enumerable.Range(1, 10)
let l = c.SomeOperation()
select c.UseIt(l).UseItAgain(l);
【问题讨论】:
-
也许发布一个您想要编写的 LINQ 示例?
-
抱歉问题不清楚。我现在已经更新了:)
标签: c# .net linq linq-to-objects