LINQ 多条件查询

cpp_1 2021-04-26 04:39:14
我用的是asp.net +EF

表结构
id name sex .....

前台有一个输入框,现在需要以‘空格’为分割符输入多姓名条件进行查询

var aa = from s in _context.aa
select s;

aa=aa.Where(s => s.name.Contains(searchString))


原来一个条件可以用Contains直接来查询

现在如果输入 【测试 用户 其它。。】这种多条件,怎么写这个表达式
...全文
2806 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
cpp_1 2021-04-27
  • 打赏
  • 举报
回复
The LINQ expression 'DbSet<PcInfo>() .Where(p => __str_0 .Any(xx => p.name.Contains(xx)))' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
guanyinsishengzi 2021-04-27
  • 打赏
  • 举报
回复

aa = aa.Where(s => str.Any( ss => s.name.Contains(ss)))
cpp_1 2021-04-26
  • 打赏
  • 举报
回复
cpp_1 2021-04-26
  • 打赏
  • 举报
回复
string[] str = { "测试", "用户" ,"其它" }; aa=aa.Where(s =>str.Contains( s.name)) 用这种方式,过滤以后,一条数据也没有了
正怒月神 2021-04-26
  • 打赏
  • 举报
回复
string[] str={测试 用户 其它} aa=aa.Where(s =>str.Contains( s.name))

8,494

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 LINQ
社区管理员
  • LINQ
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧