LINQ to Objects
LINQ to Objects refers to using LINQ's standard query operators directly against in-memory collections that implement IEnumerable<T> — arrays, List<T>, Dictionary<TKey,TValue>, HashSet<T>, and so on. Unlike LINQ to Entities (used by Entity Framework Core), there's no query translation happening: the Where and Select methods you call compile down to ordinary C# delegates (Func<T,bool>, Func<T,TResult>) that execute directly against the objects already sitting in your process's memory.
Cricket analogy: Like a domestic net session where a batter faces throwdowns from a coach standing right there — no broadcast delay, no translation — LINQ to Objects runs its Where and Select delegates directly against an in-memory List<T>, with no translation step to another query language.
How It Works Under the Hood
Most LINQ to Objects operators — Where, Select, Skip, Take — are implemented as C# iterator methods using yield return. This means they don't run immediately: calling numbers.Where(n => n > 10) just builds an iterator object. The actual predicate is only evaluated element by element when something calls MoveNext() on the resulting enumerator, typically through a foreach loop or a call like ToList(). This lazy, pull-based model is what makes LINQ to Objects memory-efficient for large in-memory sequences.
Cricket analogy: Like a bowler's run-up that only actually happens ball by ball when the umpire signals play, LINQ to Objects' Where uses a C# iterator with yield return, so each element is only tested against the Func<T,bool> predicate when MoveNext() is actually called during enumeration.
Common Operators in Practice
In everyday code, LINQ to Objects queries typically chain a handful of operators: Where to filter, Select to project into a new shape, GroupBy to bucket elements by a key, OrderBy/OrderByDescending to sort, and Aggregate or Sum/Count/Max to reduce a sequence to a single value. Because these are all extension methods on IEnumerable<T>, they work identically on an array, a List<T>, a Dictionary<T>.Values, or any custom type that implements IEnumerable<T>.
Cricket analogy: Like a scorecard that groups deliveries by bowler (GroupBy), filters to only wickets (Where), and totals runs conceded (Aggregate), LINQ to Objects chains balls.Where(b => b.IsWicket).GroupBy(b => b.Bowler) directly over a List<Ball> in memory.
var transactions = new List<Transaction>
{
new("Groceries", 84.20m), new("Rent", 1500m),
new("Groceries", 42.10m), new("Utilities", 96.50m)
};
var totalsByCategory = transactions
.Where(t => t.Amount > 50)
.GroupBy(t => t.Category)
.Select(g => new { Category = g.Key, Total = g.Sum(t => t.Amount) })
.OrderByDescending(g => g.Total);
foreach (var g in totalsByCategory)
Console.WriteLine($"{g.Category}: {g.Total:C}");LINQ to Objects works on any type implementing IEnumerable<T> — this includes Dictionary<TKey,TValue> (iterating KeyValuePair<TKey,TValue>), HashSet<T>, Stack<T>, Queue<T>, and even a custom class that implements IEnumerable<T> with its own iterator logic.
- LINQ to Objects operates on in-memory IEnumerable<T> collections: arrays, List<T>, Dictionary<T>, HashSet<T>, etc.
- It uses compiled Func<T,bool> and Func<T,TResult> delegates, not expression trees translated to another language.
- Most operators (Where, Select) are implemented as C# iterators using yield return, executing lazily.
- Predicates only run when the sequence is actually enumerated — via foreach, ToList(), or similar.
- Common chains combine Where, Select, GroupBy, OrderBy, and Aggregate/Sum/Count to transform and reduce data.
- Because it's all in-process, LINQ to Objects requires the full collection to already be in memory.
Practice what you learned
1. What interface do LINQ to Objects queries primarily operate against?
2. What kind of delegate does LINQ to Objects' Where method accept?
3. How are operators like Where and Select typically implemented internally?
4. Which of these types can LINQ to Objects query directly, given it implements IEnumerable<T>?
5. When does the predicate passed to Where actually execute in LINQ to Objects?
Was this page helpful?
You May Also Like
What Is LINQ?
LINQ (Language Integrated Query) is a set of C# language and .NET library features that let you write strongly-typed queries against in-memory collections, databases, XML, and more using one unified syntax.
Deferred vs Immediate Execution
LINQ queries either execute immediately when defined or defer execution until enumerated — understanding which operators do which prevents subtle bugs and needless repeated work.
IQueryable vs IEnumerable
IEnumerable<T> executes LINQ queries in memory using compiled delegates, while IQueryable<T> builds expression trees that a provider like EF Core translates into a remote query — mixing them up can silently pull entire tables into memory.
Related Reading
Related Study Notes in Microsoft Technologies
Browse all study notesWindows 10 / UWP Development Study Notes
.NET · 30 topics
Microsoft TechnologiesWindows Batch Scripting Study Notes
Batch · 30 topics
Microsoft TechnologiesMFC (Microsoft Foundation Classes) Study Notes
C++ · 30 topics
Microsoft TechnologiesSilverlight Study Notes
.NET · 30 topics
Microsoft TechnologiesXAML Study Notes
.NET · 30 topics
Microsoft TechnologiesWPF (Windows Presentation Foundation) Study Notes
.NET · 30 topics