About This eBook by Bart De Smet

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

Source Selection Using a from Clause

Query expressions start by the use of a from clause, which has two tasks. First, it refers to the source that’s getting queried, such as an in-memory collection or a reference to an object representing a table in a database. Second, it establishes a name for the items in that source, which is used subsequently to express filters, orderings, and so on. The following is an example:

var nums = new List<int> { 1, 2, 3, 4, 5 };from n in nums ...

Observe a few things here. On the second line, I’ve not assigned the query expression to a variable to emphasize it’s an expression. You can use the whole query expression as a parameter to a method, assign it to a variable, or whatever else ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required