Archive<< May 2020 >>
- Nurturing the next generation of Delphi enthusiasts
- TMS Business is good to go with Delphi 10.4 Sydney
- TMS WEB Core for Visual Studio Code beta is ready for TMS ALL-ACCESS users
- TMS VCL UI Pack 10.3 Major Update
- New Hands-on with Delphi book available now
- TMS WEB Core v1.4 beta is here for TMS ALL-ACCESS users
- TMS XData in a COVID-19 app: comments from the developer
- Extend TMS WEB Core with 40+ Smart HTML Elements
- Adrian Gallero (22)
- Bart Holvoet (3)
- Bernard Roussely (1)
- Bruno Fierens (247)
- Gjalt Vanhouwaert (5)
- Holger Flick (15)
- Marcos Douglas B. Santos (5)
- Masiha Zemarai (42)
- Nancy Lescouhier (32)
- Pieter Scheldeman (30)
- Roman Yankovsky (2)
- Tunde Keller (4)
- Wagner R. Landgraf (66)
BlogAll Blog Posts | Next Post | Previous Post
Monday, December 05, 2016This is the #10 feature of My Top 10 Aurelius Features. Follow the link for the full list!
Using the automapping feature is easy: you just need to add the [Automapping] attribute to your class:
type [Entity, Automapping] TCustomer = class private FId: Integer; FName: string; public property Id: Integer read FId write FId; property Name: string read FName write Name; end;
and it will automatically map the class to the database using some conventions. This prevents you from having to manually use the mapping attributes like Column, Table, Id, etc., to tell Aurelius exactly how the database schema will be.
If you already have an existing database, this is not very useful since the convention used by it will probably not match your existing database. But when you do the code-first approach (my favorite) - where you start your application creating the classes, not the tables - this is very handy.
Besides the obvious fact that Automapping speeds up the development process (prototyping is really fast with it), what I really like about Automapping is how it makes you forget about the database and think only about classes: you just don't remember you have a table or a column somewhere in the database - let Aurelius chooses whatever it needs for the underlying database, and focus on your code.
Another interesting thing is that it's not an all-or-nothing feature: you can have use the Automapping attribute but still override it with specific mapping attributes - so you get the best of both worlds: convention with flexibility:
type [Entity, Automapping] TCustomer = class private FId: Integer; [Column('CUSTOMER_NAME', [TColumnProp.Required], 120)] FName: string; public property Id: Integer read FId write FId; property Name: string read FName write Name; end;
And to conclude, here is a small video (~4 min) showing Automapping usage:
Wagner R. Landgraf
This blog post has received 3 comments.
All Blog Posts | Next Post | Previous Post