od
❔ EF8 SqlQuery with PostgreSQL, put variable as string in FormattableString
Hi,
I'm trying use SqlQuery with custom types.
_context.Database.SqlQuery<T>(@$"SELECT * FROM ""public"".{_tableName} WHERE ""Id""={Guid.Parse(id)}").SingleOrDefaultAsync();
Error: Npgsql.PostgresException (0x80004005): 42601: syntax error at or near "$1"
This line getting error cause the method converting this query to SELECT * FROM "public".@p0 WHERE "Id"=@p1
.
But I need that: SELECT * FROM "public"."Posts" WHERE "Id"=@p0
How can I do that?11 replies