Language Integrated Query (LINQ)
Language Integrated Query introduce in .NET framework 3.5. Language-Integrated Query defines a set of general purpose standard query in a integrated feature that allow traversal, filter and projection operations to be expressed in a direct yet declarative way in any programming language. These query operation can apply any Ienumerable
LINQ to Object
LINQ queries can be any IEnumerable or IEnumerable(T) collection directly without using any intermediate LINQ API’s. Enumerable collections like list(T), array and Dictionary(Tkey, Tvalue). By using LINQ we can you can override complex ForEach loops on collection for filtering, ordering or grouping data from it. The result also can be ported to other data source with little or no modification.
int[] numArray = new int[10] { 2, 54, 3, 7, 8, 3, 1, 9, 11, 10 };var numQuery = from num in numArray
where num > 10
select num;
LINQ to XML
LINQ is easy to use providing in-memory XML facility to provide Xpath/Xquery functionlity in the host programming language. It provide in-memory document modification capabilities of document object model(DOM) and support query expressions. You can bring document into the memory. You can query and modify the document and save it into the file or send it on internet after serialized it. After querying in-memory document you can retrieve its attributes and elements. Its result also used as parameters to XElement and XAttribute constructor enable powerful approach of creating XML tree. This helps developer to easily transform XML trees from one shape to another. This approach is also called functional construction.
XDocument objDoc = XDocument.Load("employee.xml");
var data = from employee in objDoc.Descendants("Employee")
where employee.Attribute("code").Value=="Emp001"
select employee;
LINQ to SQL
LINQ to SQL provide runtime infrastructure for managing relational data as objects without losing the ability to query. LINQ support main DML acitivites. You can insert, select, modify and delete information from table. When the application runs, LINQ to SQL translates into SQL LINQ query into the object model and send them to database for execution. Result is translate back to objects by LINQ to SQL on that application can work.