您好 frnds 我得到了完美的解决方案
起初使用查询
select help from Help help
然后将帮助列表存储在
var ListofHelps
然后
foreach (var item in ListofHelps)
{
if (!string.IsNullOrEmpty(searchterm))
{
var splitsearchterm = Regex.Split(searchterm, @"\s");//split search term
var splittedsubjects = Regex.Split(item.Subject.ToUpper(), @"\s"); //Subject is to be searched
var found = splittedsubjects.Where(x => x.StartsWith(searchterm.ToUpper()));
int datacount = found.Count();
if (splitsearchterm.Count() > 1 && item.Subject.ToUpper().Contains(searchterm.ToUpper()))
{
datacount = 1;
}
if (datacount > 0)
{
Helplist.Add(new HelpViewModel //Helplist is an item in HelpViewModel ie public IEnumerable<MultiSelectList> Taglists { get; set; }
{
Subject = item.Subject,
HelpId = Convert.ToInt32(item.Id),
Content = item.Content
});
}
}
else
{
Helplist.Add(new HelpViewModel
{
Subject = item.Subject,
HelpId = Convert.ToInt32(item.Id),
Content = item.Content
});
}
}
它对我有用。有没有更好的方法来做到这一点