YUNOVA · C#
Module 12: Advanced C#
Advanced LINQ and IQueryable
Key points
- IEnumerable runs LINQ in memory; IQueryable builds an expression tree.
- IQueryable providers like EF Core translate queries to SQL.
- Deferred execution means a query runs only when enumerated.
Task Parallel Library and parallel loops
Key points
- The TPL runs work on the thread pool using Task objects.
- Parallel.For and Parallel.ForEach split loop work across cores.
- Shared data in parallel loops needs locks or thread-safe collections.
Reflection and attributes
Key points
- Reflection reads types, methods and properties at runtime.
- Attributes attach metadata to code elements.
- GetCustomAttributes reads attributes, often in frameworks and serializers.
Span<T> and memory performance
Key points
- Span<T> is a view over contiguous memory without copying it.
- Slicing a span avoids new allocations for substrings or arrays.
- Span is a ref struct, so it cannot be stored on the heap; Memory<T> can.