dotnet / EntityFramework.Docs

Documentation for Entity Framework Core and Entity Framework 6
https://docs.microsoft.com/ef/
Creative Commons Attribution 4.0 International
1.63k stars 1.96k forks source link

Context Database ExecuteSqlInterpolatedAsync Executes Non Query #2088

Open ebeltran1981 opened 4 years ago

ebeltran1981 commented 4 years ago

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.

ajcvickers commented 4 years ago

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.

ebeltran1981 commented 4 years ago

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