C# / LINQ

LINQ Introduction

LINQ is an acronym for Language Integrated Query. LINQ is introduced in .NET 3.5. Before LINQ, developers need to use different languages for retrieving and saving different data sources. For example if you want to retrieve data from SQL or Oracle database you must learn some basics of SQL query language, and for retrieving data from XML files you need to learn XML parsers.

LINQ provides an unified query language for query different data sources. You can retrieve and save data into SQL/Oracle database with exactly same code. In addition LINQ provides on extension methods which helps us to write in-line queries on typed object to filter, group, join results.

LINQ variations

  • LINQ to objects
  • LINQ to SQL
  • LINQ to XML
  • LINQ to Entities

LINQ Advantages

  • LINQ helps in writing faster queries which helps in faster development.
  • LINQ queries are easier to debug.
  • Allow same query syntax for different data sources.
  • Compile-time type checking and dynamic query composition.
  • LINQ is extensible allow you to create query providers for any new data source.