.net - VB.NET : "Statement lambdas cannot be converted to expression trees" compile time error -
why can following :
dim qnodes iqueryable(of xmlnode) = xdoc.childnodes.asqueryable() dim test = qnodes.where(function(node) true)
although following gives error stated in title :
dim qnodes iqueryable(of xmlnode) = xdoc.childnodes.asqueryable() dim test = qnodes.where(function(node) return true end function)
?
i don't it.
this stated in section 11.1 of vb.net 10 language specification:
the exact translation between lambda methods , expression trees may not fixed between versions of compiler , beyond scope of specification. microsoft visual basic 10.0, lambda expressions may converted expression trees subject following restrictions:
- only single-line lambda expressions without byref parameters may converted expression trees. of single-line sub lambdas, invocation statements may converted expression trees.
- anonymous type expressions cannot converted expression trees if earlier field initializer used initialize subsequent field initializer, e.g. new {.a=1, .b=.a}
- object initializer expressions cannot converted expression trees if member of current object being initialized used in 1 of field initializers, e.g. new c1 {.a=1, .b=.method1()}
- multi-dimensional array creation expressions can converted expression trees if declare element type explicitly.
- late-binding expressions cannot converted expression trees.
- when variable or field passed byref invocation expression not have same type byref parameter, or when property passed byref, normal vb semantics copy of argument passed byref , final value copied variable or field or property. in expression trees, copy-back not happen.
all these restrictions apply nested lambda expressions well.
it restriction in first item running into. introduction leaves plenty room assume worked on in future releases, there's gained of course. connect.microsoft.com place go encourage them. couldn't check if feedback item opened this, site on fritz right now.
Comments
Post a Comment