Skip to content

Instantly share code, notes, and snippets.

@alieniasty
Last active October 23, 2017 19:26
Show Gist options
  • Save alieniasty/2cd63bbb37880ecc89a2a349ab062351 to your computer and use it in GitHub Desktop.
Save alieniasty/2cd63bbb37880ecc89a2a349ab062351 to your computer and use it in GitHub Desktop.
An expression simply turns a delegate into a data about itself. So a => a + 1 becomes something like "On the left side there's an int a. On the right side you add 1 to it."
That's it. You can go home now. Expression allows you to look inside the delegate and see everything it's wanting to do, empowering you to translate it into whatever you want, like a SQL query.
Func for example won't work for DbContext above because DbContext itself is blind to what is actually in the lambda expression and will not turn it into SQL, so it will do the next best thing and will iterate that conditional through each row in the table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment