What is LINQ?
LINQ stands for Language Integrated Query.Before LINQ developers have to use different technologies when working with different data sources.
For example to query databases developers have to use SQL.To query XML they need to use XPath.LINQ enables us to use the same language which we use to develop our application ,to query data sources.
We can use C# or VB.NET to query different data sources such as in memory collections ,databases,XML or any other data source.
What are data providers?
Data providers allows us to query different data sources using LINQ.There are different data providers for different data sources such as:
- LINQ to Objects
- LINQ to SQL
- LINQ to XML
- LINQ to ADO.NET
LINQ providers converts the LINQ queries to the queries which specific data source understands.
What are query expressions?
Query expressions are used to write LINQ queries in similar way we write SQL queries.Below is a simple query expression:
IEnumerable<int> result = from item in listItmes where item.name > "TV" select item.price;
The above query finds the price of the product “TV”.
What are the advantages of LINQ?
- It allows to write query using the same language we use to develop application
- It allows to find errors at compile time
- LINQ can be used to query any data source for which LINQ provider exists.
What is Lambda expression?
Lambda expression is like anonymous function.It does not not have a body and return type.It can assigned to a delegate.We use lambda expression in LINQ to assign it to a delegate.
It has the following form:
input arguments=>body
we can assign a lambda expression to a delegate which returns int as:
delegateMult del= x => x * x;
we can call above delegate as:
del(10);
LINQ components?
What are some LINQ providers?
- LINQ to Objects
- LINQ to SQL
- LINQ to XML
- LINQ to JSON
- LINQ to Sharepoint
LINQ components?
LINQ providers
Query operators
Language extensions
Which namespace defines LINQ extension methods?
System.Linq
What are extension methods?
Extension methods allows us to add new methods to an existing type.When we use extension methods we add new methods without modifying the existing type.
Leave a Reply