求教一个Linq里查询的问题 sql里的 select * from table where id in ('1','2') 在LinQ里怎么写呀 LinQ里有没有 in 这种方式呀?
------解决方案--------------------
如果只有两个,那就: var re = from t in table where t.id == "1" || t.id == "2" select t;
如果很多,考虑用数组: string[] idArr = {"1","2","3",....}; var re = from t in table where idArr.contains(t.id) select t;
------解决方案--------------------
------解决方案-------------------- 如果很多,考虑用数组: string[] idArr = {"1","2","3",....}; var re = from t in table where idArr.contains(t.id) select t; //我一般用字符串