What is LINQ - Part 1
Language Integrated Query
LINQ is the composition of general purpose standard query operators that allow us to work(traversal, filter and projection) with data regardless of the data source in any .net based programming language.
The standard query operators all the queries to act on any IEnumerable
LINQ to XML
Here the query operators acts on XML using an in-memory XML facility providing XPath & XQuery functionality in the .net based language.
LINQ to SQL
Here the query operators acts on relational data build on integration of SQL-based schema definitions into the common language runtime's type system
Getting Started
string[] employee =
{ "Granville", "John", "Rachel", "Betty",
"Chandler", "Ross", "Monica" };
public static void Query() {
IEnumerable
from emp in employee
where emp.Length == 5
orderby e
select e;
foreach (string item in query)
Console.WriteLine(item);
}
In the above code you can see query operators like select, where, orderby and from.
= from emp in Employee where emp.Length == 5 orderby e select e;
The above code is identical to below
= employee.Where(emp => emp.Length == 5)
.OrderBy(emp => emp)
.Select(emp => emp);
Above the arguments to the operations (Where, OrderBy and Select) are called as lambda expressions
This article will be continued.
nice one.
Can u please explain benefits of using LINQ?