[英]Why am I getting “specified cast not valid” here?
I have a column MyColumn
of type INT
and I am retrieving some rows with that column 我有一个类型为
INT
MyColumn
列,并且正在使用该列检索某些行
string selectQuery = $@" SELECT [MyColumn] FROM [dbo].[MyTable]
WHERE [Id] IN ('{testid_1}','{testid_2}','{testid_3}')
ORDER BY [MyColumn]";
var vals = mydb.ExecuteQuery<int?>(selectQuery).ToList();
where db
is of type DataContext
. 其中
db
是DataContext
类型。
Any idea why this is giving me an invalid cast exception? 知道为什么这会给我一个无效的强制转换异常吗?
这是因为下面的行试图将VARCHAR
类型转换为INT
WHERE [Id] IN ('{testid_1}','{testid_2}','{testid_3}')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.