context.Set<BlogKeyValuePair>()
.FromSql("SELECT [key], value FROM OPENJSON((SELECT JsonData FROM dbo.Blogs WHERE BlogId=1), '$.@path')",
new SqlParameter("@path", "path.to.data"));
On first sighting this should work correctly and @path should be replace by path.to.data but it doesn't, an SqlException is thrown with the following error:
System.Data.SqlClient.SqlException: Incorrect syntax near '@path'.
Seems like SQL server does not replace the parameter because it is a parameter inside the OPENJSON function.
Looking for secure workarounds.