Hello and welcome to the first in a series of posts in which I’ll be exploring LINQ.
As I’ve previously mentioned that these posts are made so that I and other people visiting this blog can refer to them quickly in time of need, I’ll try to keep the posts as clear and concise as possible.
Introduction
LINQ (short for Language INtegrated Query) is an extension to .NET languages. It allows us developers to query different sources of data.
Why do we need it?
In enterprise application development, we frequently face the need to query data. The data could be present in
- CSV
- XML
- .NET Collections
- SQL Server, Oracle, MySQL, PostgreSQL and the list goes on
For each of these data sources we need to resort to a querying API that is specific to the data source. For example XPath, XQuery, T-SQL, PL/SQL
LINQ aims to facilitate .NET developers by providing a querying API that is baked right into our favorite programming languages (i.e. C#, VB etc.) and can be extended to provide querying support to any data source. This provides a number of benefits:
- Reduced learning curve
- Reduced training costs
- Reduced risk due to type checking at compile time
- Less amount of rework in case of switching back-end data source
LINQ can be extended by using a provider pattern. Currently the following providers are available out of the box.
- LINQ to SQL
- LINQ to DataSet
- LINQ to Objects
- LINQ to Xml
- LINQ to Entities
We’ll have a look at each of these individually in forthcoming posts.
How to LINQ?
Using LINQ effectively requires us to learn some other new features that LINQ is built upon and that are also introduced in .NET 3.0. These include:
- Anonymous types
- Lambdas
- Object Initializer
- Extension Methods
In the next post I’ll cover these features and we’ll further explore LINQ in the following posts.
Bye for now