LINQ to Objects

In LINQ, if we use "LINQ to Objects" in our applications it will give us a chance to use IEnumerable or IEnumerable<T> collections directly in LINQ queries, without using any of intermediate LINQ provider or API such as LINQ to SQL or LINQ to XML. By using LINQ to Objects we can query any of enumerable collections such as List<T>, Array, or Dictionary<TKey, TValue>. 


The LINQ to Objects provides a new way to get data from collections with LINQ queries but before that, we need to write a lot of foreach loops to get data from the collections. 


The LINQ to Objects provides more advantages when compared with traditional foreach loops like


  • They provide more readability when using with multiple conditions.
  • It enables filtering, ordering, and grouping capabilities with minimal application code.
  • They are portal to any other data sources with less or no modifications.

If we use LINQ in complex operations, then we will realize the benefit of using LINQ instead of traditional iteration loops.


Now we will see how to use LINQ with objects. The following are the various objects which we can use with LINQ.


In the next chapters, we will learn how to use all these objects in LINQ with examples.