#1 2013-08-21 12:45:21

richard6688
Member
Registered: 2011-04-05
Posts: 31

TSQLRecord and SQLTableName

I have a Class such as TDictionary, they may be one class, but many tables keep same data structure. In framework, it seems generate table name automaticly, one class point to one table.

Is there any way to define many tables with one class?

Offline

#2 2013-08-21 15:49:17

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

Re: TSQLRecord and SQLTableName

Just sub-type the class with a dedicated name:

type
  TMainClass = class(TSQLRecord)
  ....
  end;

  TSQLTable1 = class(TMainClass);
  TSQLTable2 = class(TMainClass);

Here, TSQLTable1 and TSQLTable2 will create "Table1" and "Table2" tables, with the same columns.
You have to put only TSQLTable1 and TSQLTable2 in your TSQLMOdel instance, not TMainClass.

But you need one type class per table.
Otherwise, how the whole ORM stuff may work?

Offline

Board footer

Powered by FluxBB