Dapper invalid type owner

c# dapper

Question

I was just trying out Dapper for the very first time.

When I try to execute a query like the following, I encounter an ArgumentException "invalid type owner for DynamicMethod". Unlinke in this question, inserts work just fine when using Execute().

var parameters = new[] { new { accountName = name, accountPassword = password } };
var accounts = connection.Query<Account>(@"SELECT * FROM " + this.TableName + " WHERE name = @accountName AND password = @accountPassword", parameters);

I am building against .NET 4.5 on Win7.

Can anybody tell what I am doing wrong?

Accepted Answer

Your parameters should just be:

var parameters = new { accountName = name, accountPassword = password };

Not sure what you are trying to do with the new[] new




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