EntityFramework.Docs icon indicating copy to clipboard operation
EntityFramework.Docs copied to clipboard

Context Database ExecuteSqlInterpolatedAsync Executes Non Query

Open ebeltran1981 opened this issue 5 years ago • 2 comments

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.

ebeltran1981 avatar Feb 02 '20 14:02 ebeltran1981

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 avatar Feb 03 '20 22:02 ajcvickers

@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.

ebeltran1981 avatar Feb 04 '20 02:02 ebeltran1981