C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

What is LINQ - Part 1


Posted Date: 29 Jul 2008    Resource Type: Articles    Category: .NET Framework
Author: Happy CoderMember Level: Gold    
Rating: 1 out of 5Points: 10



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.



Responses

Author: Trupti    30 Jul 2008Member Level: Silver   Points : 0
nice one.
Can u please explain benefits of using LINQ?


Author: Happy Coder    31 Jul 2008Member 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 2008Member 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 2008Member 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...


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
What is LINQ  .  LINQ introduction  .  LINQ  .  C# 3.0  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: About NUnit
Previous Resource: Type Conversion Functions
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use