问题描述
用的是MVC4,想做类似词典的功能,一句英文过去,返回多个中文大家帮忙看看,下面代码有什么问题,谢谢了publicActionResultIndex(stringsearchString){List<string>lsten=newList<string>();List<string>lstzh=newList<string>();Regexex=newRegex(@"[,.()-]");searchString=ex.Replace(searchString,"");lsten.AddRange(searchString.Split(''));vardics=frommindb.Dicsselectm;for(inti=0;i<lsten.Count;i++){if(!String.IsNullOrEmpty(searchString)){dics=dics.Where(s=>s.En.Equals(lsten[i]));}}returnView(dics);}<p>@foreach(variteminModel){@Html.DisplayFor(modelItem=>item.Zh0)}</p>
解决方案
解决方案二:
publicActionResultIndex(stringsearchString){Regexex=newRegex(@"[,.()-]");varlookup=ex.Replace(searchString,"").Split('');vardics=lookup.SelectMany(x=>db.Dics.Where(y=>y.En==x));returnView(dics);}
解决方案三:
Regexex=newRegex(@"[,.()-]");->Regexex=newRegex(@"[,.()-]");