According to this [docs](https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.relationaldatabasefacadeextensions.executesqlcommand?view=efcore-2.1) and [this](https://learn.microsoft.com/en-us/ef/core/querying/raw-sql), 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"'`

1. `loggedOn` is a valid date.
2. Extracting the interpolated string to a temporary variable fixes it, however I am losing input validation for SQL injection attacks.

Am i doing something wrong or is this a bug in EFCore? Using latest EFCore 2.1
['https://Stackoverflow.com/questions/51619280', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5053000/']
As provided by @IvanStoev, the answer was to remove single quotes around the interpolated parameter.
That webpage you refer to, warns you to not have direct values inserted into SQL, that is to use parameters like so:

```
FromSql("EXECUTE dbo.GetMostPopularBlogsForUser @user", user)

```

So, adjust it to your needs and have something like:

```
FromSql("DELETE from log_entry WHERE logged_on < @logged_on", loggedOn.ToString("0"))

```

P.S. do not use double quotes `"` for the table names - either use no quotes or wrap them with `[]` as `[log_entry]`.