把这个sql语句:select * from tbl_Daily where d_u in(select u_id from tbl_users where u_name like '%王%')
用linq表达我写成这样:from list in db.tbl_Daily
where (from user in db.tbl_Users
where user.U_Name.Contains("王")
select user.U_ID) .Contains(list.D_U)
select list;
报了一下错误:
请问怎么解决呢?
var query = from t in tbl_Daily
join u in users on t.d_u equals u.u_id
where u.u_name.Contains('王');试试
SqlMethods.Like http://msdn.microsoft.com/zh-cn/library/system.data.linq.sqlclient.sqlmethods.like.aspx