Skip to main content

TableAttribute Class

Specifies a data store table to which an entity class maps its data.

Declaration

TableAttribute = class(
    TCustomAttribute
)

Remarks

Use this attribute to do the following:

  • Map an entity class to a specific data store table by passing its name as a parameter. Otherwise, the class name is considered the table name. The ‘T’ prefix is automatically removed;

  • Optionally specify a database schema within which this table is created. The specified schema name is used only if the connected database supports schemas. The table is created in the default schema (e.g., ‘dbo’ for Microsoft SQL Server databases) if the schema name is not specified. In addition to the TableAttribute, you can specify a schema name via the SchemaNameAttribute. If both the attributes specify schema names, the most recently specified one is in effect for the table.

The following code maps the TPerson entity class to the ‘MyPerson’ table created in the ‘MySchema’ database schema (e.g., in a Microsoft SQL Server database, this corresponds to a ‘MySchema.MyPerson’ table).

uses
  ..., dxEMF.Core, dxEMF.Attributes;
type
  [Entity]
  [Table('MySchema', 'MyPerson')]
  TPerson = class
  // ...
  end;

Inheritance

See Also