#1 2015-09-02 18:12:20

Junior/RO
Member
Registered: 2011-05-13
Posts: 207

Imaginary fields

I am migrating a old project with TTable/TQuery to mORMot. There are some calculated fields that I want to have in the my TSQLRecord class.

But I don't want to send this fields/calculations to the server. Example

property Volume: Double read FVolume; // or GetVolume

I need Volume in published section, because I need Volume when I convert to TSynSQLTableDataSet, for use with report generators.

Any ideas, AB?

Offline

#2 2015-09-02 18:18:25

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,183
Website

Re: Imaginary fields

Use two inherited classes?

Offline

#3 2015-09-02 19:45:18

Junior/RO
Member
Registered: 2011-05-13
Posts: 207

Re: Imaginary fields

But the mORMot engine will create the Volume field in the table? I don't need and can't have that field in the table. Can you show me some sample code?

Offline

#4 2015-09-02 20:05:38

turrican
Member
From: Barcelona
Registered: 2015-06-05
Posts: 94
Website

Re: Imaginary fields

Interface the class.

Offline

#5 2015-09-03 11:35:04

Junior/RO
Member
Registered: 2011-05-13
Posts: 207

Re: Imaginary fields

I can create a TSynSQLTableDataSet descendent and write a special case InternalInitFieldDefs. It this the best approach?

Offline

#6 2015-09-03 16:24:49

danielkuettner
Member
From: Germany
Registered: 2014-08-06
Posts: 330

Re: Imaginary fields

You could use 2 TSQLRecords, one for a VIEW in the db which has the calculated fields and one for the real table with only the none calc fields.

Last edited by danielkuettner (2015-09-03 16:25:23)

Offline

#7 2015-09-03 20:40:22

Junior/RO
Member
Registered: 2011-05-13
Posts: 207

Re: Imaginary fields

I know what to do with the TSynSQLTableDataSet descendent, but need some instructions about which methods I should override in TSQLRecord.

TSQLRecord.InitializeTable() is a options in this case?

Last edited by Junior/RO (2015-09-03 21:20:43)

Offline

#8 2015-09-04 22:00:29

Junior/RO
Member
Registered: 2011-05-13
Posts: 207

Re: Imaginary fields

Can you help me on this, @AB?

Offline

#9 2015-09-05 09:52:46

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,183
Website

Re: Imaginary fields

I can't say it better than Daniel above.
See http://synopse.info/forum/viewtopic.php … 596#p17596

Offline

Board footer

Powered by FluxBB