25

The following code when compiling gives the error message below:

'System.Data.SqlClient.SqlConnection' does not contain a definition for 'Query' and no extension method 'Query' accepting a first argument of type 'System.Data.SqlClient.SqlConnection' could be found (are you missing a using directive or an assembly reference?)

I have added Dapper using the nuget packager.

Any ideas? Thanks,

CODE:

using (SqlConnection sqlConnection = new SqlConnection(Connectionstring))
{
    sqlConnection.Open();
    Member customer = sqlConnection.Query<Member>("SELECT * FROM member");
    return customer;
}
haraman
  • 2,744
  • 2
  • 27
  • 50
James Radford
  • 1,815
  • 4
  • 25
  • 40

1 Answers1

54

You need to place a using statement in your .cs file to make the Dapper extension methods available.

using ...;
using Dapper;
using ...;
Fls'Zen
  • 4,594
  • 1
  • 29
  • 37