I have a temporal table Employee
with EmployeeHistory
as its history table.
In C#, I am using SqlConnection
to query the data from SQL Server for the entire history of an employee.
var data = Conn.ExecuteReader("select * from Employee e FOR SYSTEM_TIME ALL WHERE e.Id=15");
This throws the error:
Incorrect syntax near FOR
So, how do we query history data for a temporal table in C# using SqlConnection
?
Conn
variable. – Ermaermannoselect * from Employee FOR SYSTEM_TIME ALL WHERE Id=15
– TommySqlConnection
is only for establishing the connection to the database - in order to execute a query, you must useSqlCommand
...... – SignalmentExecuteReader
extension on theIDbConnection
interface. – Corwin