LINQ Syntax

            1. What are the necessary statements in LINQ query expression?

            2. What are from, let and where clauses?

            3. What are join, orderby, groupby clauses?

Each LINQ query starts with a “from” statement and ends with the “select” or a “group” statement. A “group” statement projects a result of a query into a set of groups, based on grouping conditions.

 

query-expression ::= from clause query-body

 

query-body ::=

join-clause*

(from-clause join-clause* | let-clause | where-clause )*

orderby-clause?

(select-clause | groupby-clause | query-continuation?

 

 

from-clause ::= from itemName in SrcExpr

select-clause ::= select selExpr

groupby-clause ::= group selExpr by keyExpr

 

The first from-clause can be followed by zero or more from, let or where clauses.

A let clause applies a name to the result of an query expression, while where clause makes a filter that will be applied to the result. A from clause represents an iteration over a collection.

 

let-clause ::= let itemName = selectExpr

where-clause ::= where predicateExpr

 

            A from clause can be followed by any number of join clause. The final select or group clause can be preceded by an orderby clause.

 

join-clause ::=

join itemName in srcExpr on keyExpr equals keyExpr

(into itemName)?

 

orderby-clause ::= orderby (keyExpr (ascending | descending)?)*

query-continuation ::= into itemName query-body

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s