[英]Search including swedish characters html-encoded
We've got an EF6 MVC3 codeFirst-site.我们有一个 EF6 MVC3 codeFirst-site。 Our news consist of two entities.
我们的新闻由两个实体组成。 newsPost with the strings Header and Introduction and newsArticle with the string Body , all nvarchar max in db.
newsPost带有字符串Header和Introduction和newsArticle带有字符串Body ,所有 nvarchar max 在 db 中。
In newsPost a swedish ö is stored as an ö in DB, but in newsArticle we have both ö and ö
在 newsPost 中,瑞典语 ö 在 DB 中存储为 ö,但在 newsArticle 中,我们同时拥有 ö 和
ö
stored (we're using ckEditor for the editing the body).存储(我们使用 ckEditor 来编辑正文)。
When the user sends a string searchword it's easy to search for matches in the posts, but for the articles I would like to search for both the searchword and the html-encoded searchword.当用户发送一个字符串搜索词时,很容易在帖子中搜索匹配项,但对于文章,我想同时搜索搜索词和 html 编码的搜索词。
I guess I want to write something like this我想我想写这样的东西
var htmlEncodedSearchword= Html.Encode(searchword);
var postIds = context.News.Where(m => m.Body.Contains(searchword)||m.Body.Contains(HtmlEncodedSearchword)).OrderByDescending(x=>x.PublicDate).Select(x => x.PostId).ToList();
...but I can't figure out how to do. ...但我不知道该怎么做。
There is a method WebUtility.HtmlEncode
which does that有一种方法
WebUtility.HtmlEncode
可以做到这一点
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.