newbie with dapper and c#

.net c# dapper

Question

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;
}

Accepted Answer

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

using ...;
using Dapper;
using ...;


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why