为什么这是不可能的:
... new DB().ExecuteQuery<String>(@"Select {0} From {1} ", selectParam, tableParam);
这会引发以下异常:必须声明表变量“@p1”。
谢谢
最佳答案
@ before the "" says to compiler that this is a string nothing else
在这里阅读 http://msdn.microsoft.com/en-us/library/362314fe(v=vs.71).aspx
Must declare the table variable "@p0"
好像不一样Edited
: 不要使用表名作为参数最好只使用你的表名,它会导致sql注入(inject)请阅读http://en.wikipedia.org/wiki/SQL_injection
关于LINQ-to-SQL:为什么我不能使用表名作为参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5895589/