c# - Convert simple SelectMany into query syntax -
the following simple form of selectmany()
. how if @ can convert query syntax?
var array = new string[] { "shaun", "luttin" }; array .selectmany( s => s );
the best can produces same output introduces new variable c
...
var query = s in array.asqueryable() c in s select c;
...and results in following fluent syntax.
array .selectmany ( s => s, (s, c) => c );
re: possible duplication
i have read answers is there c# linq syntax queryable.selectmany() method? i'm afraid answers' translation's not compile original fluent syntax.
the compiler performs translation turn query syntax method syntax. details specified in section 7.6.12 of c# 5 spec. quick search turns couple translations can result in call selectmany
, in section 7.6.12.4:
a query expression second clause followed select clause:
x1 in e1
x2 in e2
select v
translated( e1 ) . selectmany( x1 => e2 , ( x1 , x2 ) => v )
and
a query expression second clause followed other select clause:
x1 in e1
x2 in e2
…
translated into
from * in ( e1 ) . selectmany( x1 => e2 , ( x1 , x2 ) => new { x1 , x2 } ) …
so there appears no translation results in other overload of selectmany
being called.
Comments
Post a Comment