Reputation: 13
Dapper 1.34 (on earlier Dapper ver like 1.1x this worked fine).
db.Query(@"Select [whatever] from @TableName Where [PREFIX]='@Prefix' order by [something] desc", new { TableName = tableName, Prefix = prefix })
Error: System.Data.SqlClient.SqlException (0x80131904): Must declare the table variable "@TableName".
I get same error trying to define DynamicParameters and passing those.
======= I am currently doing string substitution {%1} .. but that does not seem acceptable ...
Can I please get a sample, also looking at test class for dapper I cant see it running, maybe something wrong with my project setup ?
Upvotes: 1
Views: 1437
Reputation: 1064204
No, that has never worked fine, due to how SQL works:
DataTable
as a table-valued-parameter, though - which dapper does support - but I don't think this is what you are after'@Prefix'
is a string literal; you just mean @Prefix
(no single quotes)Upvotes: 0