如何使用 Entity Framework Core 进行全文搜索添加两个字段?
如果只搜索一个字段,就可以成功。 但不是两个。
var results = db.tables
.Where(x => EF.Functions.Match(x.Title, "search text",MySqlMatchSearchMode.Boolean));
我想得到sql语法结果。
select * from articles
where match(`title`) against('葡萄牙') > 0;
下面是我想要达到的结果。
var results = db.tables
.Where(x => EF.Functions.Match(x.Title+x.ArticleContent, "search text"));
我想得到sql语法结果。
select * from articles
where match(`title`,`article_content`) against('葡萄牙') > 0;
错误 : MySqlConnector.MySqlException (0x80004005):您的 SQL 语法有错误;检查与您的 MariaDB 服务器版本相对应的手册,了解在 '(s
.title
, COALESCE(s
.article_content, ''))) AGAINST ('葡萄牙' IN BOOL...' 第 3 行
If only one field is searched, it can be successful.
But not two.
var results = db.tables
.Where(x => EF.Functions.Match(x.Title, "search text",MySqlMatchSearchMode.Boolean));
I want to get sql syntax result.
select * from articles
where match(`title`) against('葡萄牙') > 0;
Below is the result I want to achieve.
var results = db.tables
.Where(x => EF.Functions.Match(x.Title+x.ArticleContent, "search text"));
I want to get sql syntax result.
select * from articles
where match(`title`,`article_content`) against('葡萄牙') > 0;
Error :
MySqlConnector.MySqlException (0x80004005): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(s
.title
, COALESCE(s
.article_content
, ''))) AGAINST ('葡萄牙' IN BOOL...' at line 3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为我找到了答案,所以分享答案
网址:
Because I found the answer, share the answer
URL : <https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/blob/f4b1ab9497743db5a395a36340515b3d3fc28e3c/test/EFCore.MySql.FunctionalTests/Query/MatchQueryMySqlTest.cs >