Domanda

I know I can walk a linq expression tree and emit the IL code by myself. But i'm trying to avoid that. In this case, using the CodeDom or the Roslyn compiler is not an option (I have to start from an existing set of linq expressions generated by a propietary DSL). Any ideas? Thanks!

È stato utile?

Soluzione

You can compile an expression to an assembly by using CompileToMethod(). This has some restrictions, most notably that the MethodBuilder that you pass to the method has to be for a static method. But otherwise this should be exactly what you're asking for.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top