LINQ query syntax and query expression
With built-in LINQ extension methods and lambda expressions, Visual Studio allows us to write SQL-like statements in C# when invoking these methods. The syntax of these statements is called LINQ query syntax and the expression in query syntax is called a query expression.
For example, we can change the following statement:
var veges6 = products.Where(p => p.ProductName.Contains("vegetable"));
To the following query statement by using the LINQ query syntax:
var veges7 = from p in products where p.ProductName.Contains("vegetable") select p;
In the above C# statement, we can directly use the SQL keywords
where to "query" an in-memory collection list. In addition to the in-memory collection lists, ...