首页 新闻 赞助 找找看

linq to entity 动态拼接问题

1
悬赏园豆:20 [待解决问题]

有个Employee表,我想根据EmployeeID 进行模糊查询(EmployeeID 是string类型);

我获得了 一个string[] empID={"111","222","333"},要用数组里的数据去查出Employee表的数据,最好用linq to entity 去写。

Gordon_天下的主页 Gordon_天下 | 初学一级 | 园豆:180
提问于:2011-09-15 18:46
< >
分享
所有回答(2)
0
from e in Employee where empID.Contains(e.EmployeeID) select e;
生成的sql语句为:
select*from Employee as e where e.EmployeeID in {"111","222","333"}
today4king | 园豆:3499 (老鸟四级) | 2011-09-15 20:10
0

var query=entities.Employee.where(c=>empID.contains(c.EmployeeID));

RyanCheng | 园豆:474 (菜鸟二级) | 2012-11-27 14:29
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册