I have researched this and always found examples like this:
var blogs = context.Blogs
.FromSql("SELECT * FROM dbo.Blogs")
.ToList();
The problem is, I don't want to run my raw SQL on the Blogs table. Basically, I want to implement an interface like this:
bool ExecuteNonSafeSql(
string connectionString,
string sql);
Is there a way to do that with DbContext?
context.Database
likecontext.Database.ExecuteSqlCommand()
orcontext.Database.SqlQuery()
. Which to use depends on what exactly you want to do. What would be the return value of your statement? – Deliladelilahtrue
is returned. Otherwise, afalse
. – Weismannism