LINQ Presentation With Examples
LINQ Presentation With Examples
Query)
Understanding LINQ in .NET with
Examples
Introduction to LINQ
• • LINQ (Language Integrated Query) allows
querying data in C# directly.
• • It was introduced in C# to unify the way
developers work with data.
• • LINQ is similar to SQL but integrated within
the language.
• • Sorting (OrderBy):
• var sorted = numbers.OrderBy(x => x);
• • Projection (Select):
• var projection = people.Select(p => p.Name);
Advanced LINQ Features
• • Deferred Execution: Queries are not
executed until results are enumerated.
• Example:
• var query = numbers.Where(x => x > 5); //
No execution yet
• foreach(var num in query) // Execution
happens here