What is the LINQ?
LINQ is the “Language integrated Query language”. It contains a set of new language features of C# and Vb.net. We can write the structure queries in our own languages (i.e. Vb.net or C#).
Simple example of a LINQ query:
var words = new List<string> {“Orange”, “apple”, “Mango”};
var results = from w in words
where w.Contains(“O”)
select w;
Advantages
- We can write the complex sql query in a simple manner.
- It makes easier to transform data into objects.
- A common syntax for all data. Once you learn query syntax, you can use it with any LINQ provider
- Provider integration. Pulling together data sources is very easy.
- Built-in security. It forced to use of parameters, helping to reduce SQL injection attacks. LINQ to SQL already parameterizes input, which is just as secure.
- It supports Object/Relational Mapper (O/RM) which automatically generates entity classes based on the database schema, so it helps speed up development of n-layer architecture applications
- It will be useful in Silverlight Technology since Silverlight does not support ado.net features.
- It makes easier to develop applications by providing IntelliSense, compile-time syntax checking, and debugging support.
Note: Before reading LINQ we should have to learn the New Features of C# 3.0