LINQ to Object

Posted by in C# category on for Beginner level | Points: 250 | Views : 9164 red flag
Rating: 5 out of 5  
 1 vote(s)

In this article we will see how we LINQ can be used with class objects.


LINQ -  Language Integrated Query a flexible query like language introduced in C# to query any data set, whether database, XML, or just plain objects.

We will see some samples on how LINQ queries can be used to query Object collections.

1. First we will create couple of class objects

2. Let us populate some data in the objects

3. Now let us query the emp data using LINQ.

4. Now let us sort the emp data based on Age.

5. Now Let us sort the emp data based on multiple columns Ename and Age

6. Let us now filter the emp data based on Ename.

7. Let us now filter data based on multiple conditions

8. Let us use joins between Emp and Dept objects

You see how simple it is to use LINQ with class objects. Similarly we can use many such LINQ queries on class objects.

Hope you all will get benefit out of this. Do share your comments and or feedback. 
Page copy protected against web site content infringement by Copyscape

About the Author

Full Name: Madhu Rokkam
Member Level: Bronze
Member Status: Member,MVP
Member Since: 1/13/2011 3:13:20 PM
Country: India
Thanks and Regards Madhu

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)