木子屋 Dnawo's BLOG

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

👤 dnawo 📅 2009-08-18 👁 5657 👍 0 💬 0 🔄 来源:本站原创
在数据集(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)

暂无评论。

验证码
评论需审核通过后显示
← 上一篇 一句话完成多条件查询 下一篇 → C#获取应用程序路径几种方法