liveBook · Manning

Reflection

As explained in Building Web APIs with ASP.NET Core

Reflection is the programmatic inspection of a type's metadata, members, and structure at runtime.

Reflection is the programmatic inspection of code metadata, members, and structure at runtime. In a validation scenario, it can inspect an entity or DTO type and check whether a requested sort column matches an available property. section 6.1.3

Validating a sort column

A SortColumnValidatorAttribute accepts an EntityType value, reads the supplied column name, and calls EntityType.GetProperties().Any(p => p.Name == strValue). The controller applies it with [SortColumnValidator(typeof(BoardGameDTO))], allowing valid DTO properties while avoiding direct exposure of sensitive entity properties such as password hashes. section 6.1.3

How Building Web APIs with ASP.NET Core covers it

How deep it goes
Demonstrates property inspection through GetProperties and stops short of broader reflection APIs or internal runtime mechanics.
Examples
Uses SortColumnValidatorAttribute to compare a requested sort column with BoardGameDTO properties.
What it assumes
Assumes familiarity with validation attributes, controller parameters, types, and DTOs while identifying reflection by name.
What you can do after
Apply it via a custom validation attribute that checks requested names against a selected .NET type's properties.
How it connects
Connects reflection with custom validation attributes, DTOs, data validation, and the System.Reflection namespace.

Also explained in

Compare how 13 books explain reflection →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Web APIs with ASP.NET Core. The section links point to the parts of the book it draws on.