다음 오류가 발생하지만 내 성명을 다시 쓰는 방법을 모르십니까? 아이디어가 있으십니까?Entity Framework - 문자열 변환 오류
오류 :
LINQ to Entities does not recognize the method 'System.String Convert(System.String)' method, and this method cannot be translated into a store expression
코드 :
public Client FindClientByMobile(string mobile, string accountId)
{
Client client = RepositorySet.Include("Account").FirstOrDefault(c => c.AccountId == accountId && !c.IsDeleted
&& ((Convert(c.TelephoneHome) == mobile) || (Convert(c.TelephoneMobile) == mobile) || (Convert(c.TelephoneWork) == mobile)));
return client;
}
public static string Convert(string mobile)
{
var filterNumber = from letter in mobile
where char.IsDigit(letter)
select letter;
StringBuilder number = new StringBuilder();
number.Append(filterNumber.ToArray());
return number.ToString();
}
이 오류는 Linq가 표현을 Sql 문으로 변환해야 함을 의미합니다. 커스텀'Convert' 메쏘드는 데이터베이스 서버에 존재하는 것이 아니라 C# 코드이기 때문에 번역 할 수 없습니다. – Igor
안녕하세요, 고맙지 만 이미 문제를 언급했지만 질문했지만 문안을 다시 작성하는 방법을 모르십니까? –
전화 번호가 문자열에 있습니다 –