'Acquire audit properties from Temporal table C# core EF

I would like to retrieve the createdAt, CreatedBy, ModifiedAt, ModifyBy, DeletedAt and DeletedBy properties from MSSQL temporal table.

In temporal table I only store who wrote the record last (this way I can prevent from modifying the ModifiedAt datetime record in C# code at SaveChanges() which would save a new record in temporal table even if no property changed)

But how could I retrieve the above mentioned properties?

SELECT top(1) PeriodEnd AS CreatedAt FROM dbo.***History ORDER BY PeriodStart DESC; SELECT top(1) PeriodEnd AS LastModifiedAt FROM dbo.***History ORDER BY PeriodStart ASC;

But after the first record only, the history is still empty. And I would like these in EF not in plain SQL.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source