I have this search terms
[HttpPost]
public ActionResult Index(string searchString)
{
if (!String.IsNullOrEmpty(searchString))
{
students = students.Where(s => s.FIRST_NAME.Contains(searchString)
|| s.LAST_NAME.Contains(searchString)
|| s.PERSONAL_NUMBER.Contains(searchString)
|| s.ACD_UNI_DEGREES.DEGREE.Contains(searchString)
|| s.ACD_UNI_FACULTIES.FACULTY.Contains(searchString)
|| s.ACD_UNI_SPECIALIZATIONS.SPECIALIZATION.Contains(searchString)
|| SqlFunctions.StringConvert(s.SEMESTER).Contains(searchString)
|| s.COR_PAYER_STATUS.NAME.Contains(searchString)
|| SqlFunctions.StringConvert(s.CREDIT_COUNT).Contains(searchString));
}
return View(students.ToList());
}
but on debugging it throws an exception:
System.NotSupportedException: The specified method 'System.String StringConvert(System.Nullable`1[System.Decimal])' on the type 'System.Data.Objects.SqlClient.SqlFunctions' cannot be translated into a LINQ to Entities store expression.
The problem is here:
SqlFunctions.StringConvert(s.SEMESTER).Contains(searchString)
SEMESTER is decimal and searchString is string. How can I improve that?