首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

Linq查询有关问题;

2011-12-18 
Linq查询问题.string str 1,2,3,4查询的时候要用,分隔我不知道用LINQ怎么查,我就写下SQL的查法吧!

Linq查询问题;.
string str = "1,2,3,4";

查询的时候要用','分隔

我不知道用LINQ怎么查,我就写下SQL的查法吧!

select * from s where id= 1 or id= 2 or id= 3 or id=4
 
用LINQ的话 是怎么实现呢?

[解决办法]
string[] s = str.Split(new char[]{','});

var query = from dt in table where s.Contains(dt.ID.ToString()) select dt

[解决办法]
直接用var query = from dt in table where str.Contains(dt.ID.ToString()) select dt 可能也可以

热点排行