日期:2014-05-20  浏览次数:20791 次

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 可能也可以