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 based datasource.
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 resultSet = 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.
|
| Author: Trupti 30 Jul 2008 | Member Level: Silver Points : 0 |
nice one. Can u please explain benefits of using LINQ?
|
| Author: Happy Coder 31 Jul 2008 | Member Level: Gold Points : 2 |
LINQ is a new addition to .NET that lets us to query inline data / in-memory date as they probably would be used to doing with standard SQL-type syntax.
AS in above example you could see, "employee" is an in memory array(can also use collection) and we are getting the results in a similar way as we query a table.
Note: This works only >= C# 3.0
|
| Author: Happy Coder 31 Jul 2008 | Member Level: Gold Points : 2 |
LINQ is a new addition to .NET that lets us to query inline data / in-memory date as they probably would be used to doing with standard SQL-type syntax.
AS in above example you could see, "employee" is an in memory array(can also use collection) and we are getting the results in a similar way as we query a table.
Note: This works only >= C# 3.0
|
| Author: Trupti 31 Jul 2008 | Member Level: Silver Points : 1 |
Oh thanks for information. But actually what i want to asked is when and in which type of application we prefer to use LINQ? b'coz as per my knowledge there are some limitation in to LINQ it self like it does not support nested inner query...
|