select id,name,age from table1 where id in(@id)vs自动为我们生成了方法:
public virtual Northwind.TABLE1DataTable List(int id);注意,这边id是int类型,虽然在属性面板中我们可以将id改为string类型,但最终仍是不能查询:

变通下,使用charindex代替in可实现要求:
select id,name,age from table1 where charindex(','+convert(varchar,id)+',',','+@ids+',')>0
ACCESS版:
select id,name,age from table1 where instr(',' + ? + ',', ',' + cstr(Id) + ',')>0
评论(0)
暂无评论。