Consider the following TSql code:
CREATE TABLE Employee
(
[EmployeeID] int NOT NULL PRIMARY KEY CLUSTERED
, [Name] nvarchar(100) NOT NULL
, [Position] varchar(100) NOT NULL
, [Department] varchar(100) NOT NULL
, [Address] nvarchar(1024) NOT NULL
, [AnnualSalary] decimal (10,2) NOT NULL
, [ValidFrom] datetime2 (2) GENERATED ALWAYS AS ROW START
, [ValidTo] datetime2 (2) GENERATED ALWAYS AS ROW END
, PERIOD FOR SYSTEM_TIME (ValidFrom, ValidTo)
)
WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE = dbo.EmployeeHistory));
... and the following C# code using DACFx:
TSqlObject table;
TSqlObject nameColumn;
// picture some code instantiating the two variables above
var primaryKey = table.GetChildren().Single(x => x.ObjectType == ModelSchema.PrimaryKeyConstraint);
var isMax = nameColumn.Object.GetProperty<bool?>(Column.IsMax);
So here we see that I've queried the DACFx API to find out if the column instance is a MAX-kind of column, and to get information on the table's primary key.
Now I would like to know about the temporal setup of the table. I need to know if SYSTEM_VERSIONING
is on, and if it is, what is the table that serves as the history table. I also would like to know which fields are used as the row start and end.
How can I know this using DACFx API?