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 intermediate LINQ provider or API such as LINQ to SQL or LINQ to XML. Using LINQ to Objects, we can query any 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 used with multiple conditions.
  • It enables filtering, ordering, and grouping capabilities with minimal application code.
  • They are portable to any other data source with fewer 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 following chapters, we will learn how to use all these objects in LINQ with examples.