Context Database ExecuteSqlInterpolatedAsync Executes Non Query
I am trying to get a query result from a script that builds a temp table . I am executing: ExecuteSqlInterpolatedAsync and ExecuteSqlRawAsync and they both return an int... digging a bit more, found that both in the underline code execute this: rawSqlCommand.RelationalCommand.ExecuteNonQuery
how am I supposed to execute a query when I dont have an entity in the database? The documentation suggests that this is possible.
thanks for your help.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 5ac0e657-7fca-4086-3f92-85731661a2bb
- Version Independent ID: 39e02a50-bbde-b95c-22df-5bd1ee43893f
- Content: RelationalDatabaseFacadeExtensions.ExecuteSqlRaw Method (Microsoft.EntityFrameworkCore)
- Content Source: dotnet/xml/Microsoft.EntityFrameworkCore/RelationalDatabaseFacadeExtensions.xml
- Product: entity-framework-core
- GitHub Login: @dotnet-bot
- Microsoft Alias: divega
Note for team: looks like the docs may be misleading here.
@ebeltran1981 It's not 100% clear to me what you want here, but https://github.com/dotnet/efcore/issues/11624 and https://github.com/dotnet/efcore/issues/10753 are open issues that may be tracking support for what you are looking for.
@ajcvickers thanks for the issues refs, it is related to my issue... I did not find them when searching for this... interestingly I end up doing the same solution they suggest it...
removing the context.Database.ExecuteSqlRaw("SELECT * FROM [dbo].[SearchBlogs]({0})", userSuppliedSearchTerm) will help to avoid any confusion.
Will close this. Thanks for your help.