liveBook · Manning

Client-side evaluation

As explained in Grokking Software Architecture

Client-side evaluation is the execution of a query operation in application memory rather than by the database engine.

Client-side evaluation happens when an ORM cannot translate part of a query into SQL, so the filtering must happen in application memory. A custom C# helper such as CalculateAge(u.DOB) can trigger the problem. section 8.3.2

The consequences depend on the ORM:

  • Older ORMs such as EF6 could silently fetch the whole table and filter it in memory; a query meant to return 10 rows could fetch 10 million. section 8.3.2
  • EF Core 3+ throws a runtime exception when it cannot translate the expression, protecting the database but failing the request. section 8.3.2
  • Rewrite the query using SQL-compatible logic, or explicitly fetch only the needed data before filtering it in memory. section 8.3.2

How Grokking Software Architecture covers it

How deep it goes
Traces a C# translation failure through older and modern ORM behavior, then gives two remedies.
Examples
Uses a CalculateAge voter query to contrast fetching millions of rows with a translation exception.
What it assumes
Assumes familiarity with C#, ORM queries, and SQL translation.
What you can do after
Diagnose translation failures from a LINQ exception and choose SQL-compatible logic or explicit in-memory filtering.
How it connects
Links ORM query translation with SQL, LINQ, and filtering in application memory.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.