8,497
社区成员
发帖
与我相关
我的任务
分享
var search =
from info in context
where (txtName == "" || info.name == null || info.Sname.Contains(txtName)) //模糊查询
&&(info.password == txtPassword) //精确查询
select info;
var search = from info in context
where info.password == txtPassword //精确查询
select info;
if(!string.IsNullOrEmpty(txtName))
{
search =search .Where(s=>s.Sname.Contains(txtName));
}