如何在实体框架中使用替换方法。我使用下面的代码,但遇到错误。LINQ to Entities不能识别Replace方法?
using (SepasProjectEntities sp=new SepasProjectEntities())
{
var query = (from p in sp.HISAccidentLocationMappings
where p.Name.Replace('y','x').Contains(txt1.Text)
select p
).ToList();
}
An exception of type 'System.NotSupportedException' occurred in System.Data.Entity.dll but was not handled in user code
Additional information: LINQ to Entities does not recognize the method 'System.String Replace(Char, Char)' method, and this method cannot be translated into a store expression.
我应该为'replace'方法做些什么? –
@RaymondMorphy检查我的答案。 – Kehlan