Skip to content

How to create type strong tables ?

Arnaud Declercq edited this page Mar 12, 2021 · 2 revisions

About type-strong tables

The SQL adapter provide the capability to associate a BHoM type with each table. This means that

  • Rows pulled from a "type-strong' table will automatically be converted to objects of that type.
  • If there is only one table associated with a given type, the user can push objects of that type without having to specify the target table.
  • The adapter will refuse to push objects of a type that doesn't match the type of the table.

How to associate a type with a table ?

  • Create a new table in your database and call it _tableTypes (the casing is important).
  • The table columns should be defined as follows:
Column Name Date Type Allow Nulls
TableName varchar(255) no
TypeName varchar(255) no

The TypeName value corresponds to the namespace followed by the type name (e.g. BH.oM.Geometry.Point). In doubt, you can generate the TypeName as with this simple script:

image

Note that generic types are not supported.

Clone this wiki locally