You can't do that directly with C# - the language does not support it.
You can do it; you can create code, compile, and run it from inside an app:
How to programmatically compile code using C# compiler[
^] but it's not a good solution for general purpose work - it's goign to be hard to maintain, hard to control, and unless you are very careful it effectively hands control of your application internals to the user.
I can't think of a good reason to do that that putting the Linq code in a method instead wouldn't be a better solution.