Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FromSqlRaw() - inconsistent/incorrect documentation #25567

Closed
wschlegel opened this issue Aug 18, 2021 · 0 comments · Fixed by #25568
Closed

FromSqlRaw() - inconsistent/incorrect documentation #25567

wschlegel opened this issue Aug 18, 2021 · 0 comments · Fixed by #25568
Assignees
Labels
area-docs area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@wschlegel
Copy link

When I follow this documentation: https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.relationalqueryableextensions.fromsqlraw?view=efcore-5.0 I get an error message:

FormatException: Input string was not in a correct format.

Example:

Context.Entity.FromSqlRaw("SELECT * FROM dbo.SomeFunction({@MyParameter})", new SqlParameter("@MyParameter", "some value"))

However, when I follow this documentation: https://docs.microsoft.com/en-us/ef/core/querying/raw-sql, the SQL created is sound and the query is executed correctly:

Example:

Context.Entity.FromSqlRaw("SELECT * FROM dbo.SomeFunction(@MyParameter)", new SqlParameter("@MyParameter", "some value"))

Here the parameters are specified without curly braces - which I think is logical, since there is no string interpolation going on here.

It seems to me that parts of the documentation are wrong.

Hence, I suggest adjusting the documentation and removing the curly braces when passing in named parameters.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@roji roji transferred this issue from dotnet/EntityFramework.Docs Aug 18, 2021
@roji roji self-assigned this Aug 18, 2021
@roji roji added area-docs area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. labels Aug 18, 2021
roji added a commit that referenced this issue Aug 18, 2021
roji added a commit that referenced this issue Aug 18, 2021
roji added a commit that referenced this issue Aug 18, 2021
@ajcvickers ajcvickers added this to the 6.0.0-rc2 milestone Aug 26, 2021
@ajcvickers ajcvickers modified the milestones: 6.0.0-rc2, 6.0.0 Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-docs area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants