Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Data.SqlClient.SqlConnection does not contain a definition for Query with dapper and c#

Tags:

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; } 
like image 971
James Radford Avatar asked Dec 26 '12 15:12

James Radford


1 Answers

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

using ...; using Dapper; using ...; 
like image 196
Fls'Zen Avatar answered Oct 23 '22 15:10

Fls'Zen