Skip to content

Visual Studio C# Error message : Error 4 ‘System.Data.IDbConnection’ does not contain a definition for ‘Query’ and no extension method ‘Query’ accepting a first argument of type ‘System.Data.IDbConnection’ could be found (are you missing a using directive or an assembly reference?)

Following Error message generated for the below coding snap

var GenError = conn.Query<ClassName>(cmd, new { parameter1, parameter2 }, commandType: CommandType.StoredProcedure).ToList();

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

Solution is

Import the following namespace

using Dapper;