.NET数据集(xsd)使用in查询

在数据集(xsd)中有时我们要进行in查询:

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 | 引用: 0 | 查看次数: 4858
发表评论
登录后再发表评论!