7

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?

Community
  • 1
  • 1
Structed
  • 304
  • 8
  • 19

1 Answers1

10

Your parameters should just be:

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

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

E.J. Brennan
  • 45,870
  • 7
  • 88
  • 116
  • Thank you and @chappoo for this hint. Carried it over from the insert example. But of course, it doesn't make sense here. Thanks a lot! – Structed May 26 '14 at 09:20