The Identity Map: what it gives you, what it hides
Here’s a pattern that shows up in almost every ORM-backed codebase, written by people who don’t realize it: LOrder := LContext.Get<TOrder>(42); // ... do something ... LOtherOrder := LContex...
Here’s a pattern that shows up in almost every ORM-backed codebase, written by people who don’t realize it: LOrder := LContext.Get<TOrder>(42); // ... do something ... LOtherOrder := LContex...
A TOrder has a CustomerID. Sometimes, when the code holds an order, it also needs the Customer. Sometimes it doesn’t. A naïve ORM fetches the customer eagerly on every Get<TOrder>. That’s si...
Two users open the same invoice. Alice edits the amount and clicks Save. Bob, a minute later, edits the customer and clicks Save. Alice’s amount is gone. Bob overwrote it with the value he loaded a...
The previous post ended with a promise: after hooks exist, we’ll come back to them. This is that post. Trysil has two complementary mechanisms for reacting to persistence operations. One is the me...
Most ORMs treat validation as someone else’s problem. You write your entities; you write your service layer; somewhere in that service layer there’s a Validate(entity) method that nobody maintains ...
Attribute-driven SQL is where most ORMs earn their keep. [TTable], [TColumn], [TJoin], a filter — and the framework hands you back typed entities. It covers 80% of real queries. The remaining 20% ...
Delphi has FireDAC. FireDAC already talks to SQLite, PostgreSQL, Firebird, SQL Server, MySQL, Oracle, and a handful of others. If connectivity is a solved problem, why does Trysil need a driver lay...
Trysil is code-first. You write a plain Delphi class, decorate it with [TTable], [TColumn], [TPrimaryKey] and the rest, and the framework does the mapping. That’s the model you’ve seen in every pos...
Every application eventually needs the same four things on its important tables: when was this row created, by whom, when was it last updated, by whom. Some applications also want a fifth and sixth...
In the first post we fetched every row with SelectAll<TPerson>. That’s fine when the table has ten rows. At ten thousand, it isn’t. This post walks through the three ways Trysil lets you fil...