LINQ Interview Question #5
What is query syntax in LINQ?
LINQ Fundamentals, Syntax, IEnumerable & IQueryable Junior Beginner
Quick Interview Answer
Query syntax is the SQL-like C# syntax that uses keywords such as from, where, orderby, select, group, and join. The compiler translates supported query expressions into calls to standard LINQ methods.
Detailed Explanation
Query syntax is the SQL-like C# syntax that uses keywords such as from, where, orderby, select, group, and join. The compiler translates supported query expressions into calls to standard LINQ methods.
Query syntax can be especially readable for complex joins or grouping, but it does not provide a fundamentally different execution engine from the equivalent method syntax.
Code Example
var result =
from product in products
where product.Price > 100
orderby product.Name
select product;