EF.Functions.包含多个关键字 [英] EF.Functions.Contains including multiple keywords

查看:526
本文介绍了EF.Functions.包含多个关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要搜索多个列(使用下面的||语句工作的LearningingModuleDesc和LearningModuleContent),但是我还需要搜索多个关键字. .Net Core 2.2和EF Core不支持包含Contains的字符串数组(如下面的示例),但是一些有关如何进行此操作的指导非常有用.

I need to search on multiple columns (LearningModuleDesc and LearningModuleContent which works using the || statements below) but I also need to search on multiple keywords. .Net Core 2.2 and EF Core does not support the string array with Contains (like the example below) but some guidance of how I would go about this would be great.

string[] stringarray = new string[] { "mill", "smith" };

var results =  _context.LearningModules
.Where(x => EF.Functions.Contains(x.LearningModuleDesc, stringarray)
|| EF.Functions.Contains(x.LearningModuleContent, stringarray)
);

推荐答案

如果我正确理解,您正在寻找类似的东西

If I understand correctly, you are looking for something like this

 var results = _context.LearningModules.Where(
   x => stringarray.Any(t => x.LearningModuleDesc.Contains(t)) || 
        stringarray.Any(t => x.LearningModuleContent.Contains(t)))

这篇关于EF.Functions.包含多个关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆