0

I am trying to execute a sql command directly against the database. However, intellisense does not see ExecuteQuery as a valid method against my context variable. I am sure I am missing something obvious.

My context class:

 public class CatastropheContext : DbContext
 {
     public DbSet<CLIENT> CLIENTs { get; set; }
     ...
 }

My attempt to establish the query:

CatastropheContext db = new CatastropheContext();
IEnumerable<ClientClaim> = db.ExecuteQuery

In the code above, ExecuteQuery is flagged as invalid an intellisense suggests creating a stub method.

2 Answers2

2

Can you use Database.ExecuteSqlCommand where Database comes from the DbContext class.

Sachin Kainth
  • 45,256
  • 81
  • 201
  • 304
0

This seems to me like you are missing some references. Make sure you are:

using System.Data.Linq;

Here is the MSDN reference on ExecuteQuery. Notice the namespace.

Justin Pihony
  • 66,056
  • 18
  • 147
  • 180