Only for basic objects.
The minute you add relationships your approach becomes unusable.
There is a reason ORMs have persisted for over 30 years.
The minute you add relationships your approach becomes unusable.
There is a reason ORMs have persisted for over 30 years.
Congratulations, you've invented an ORM.
An ORM library maps an entire relational database to a graph of objects, with the intention of abstracting away the relational database. Copying query results to structs doesn't actually do any of that.
https://en.m.wikipedia.org/wiki/Object%E2%80%93relational_ma...
But then it's nice to have something that generates optimised, database-specific SQL, can handle date/number conversion, supports many-many relationships, converting BLOB to binary streams etc.
Source: Wrote an ORM that other people actually use. Still adding features, twelve years later.