According to this docs and this, I should be able to pass an interpolated string to ExecuteSqlCommandAsync
like this:
public async Task DeleteEntries(DateTimeOffset loggedOn) {
await myContext.Database.ExecuteSqlCommandAsync(
$"DELETE from log_entry WHERE logged_on < '{loggedOn}';"
);
}
However, it gives me the following error: Npgsql.PostgresException: '22007: invalid input syntax for type timestamp with time zone: "@p0"'
loggedOn
is a valid date.Am i doing something wrong or is this a bug in EFCore? Using latest EFCore 2.1
As provided by @IvanStoev, the answer was to remove single quotes around the interpolated parameter.