i'm a Asp.net MVC Develpoer and i have problem with converting string to int because i
because i nedd it on search. When i tryed to write this code on the Contoller:
public ViewResult Search(string textboxmvc)
{
var student = from i in db.StudentSet select i;
if (!String.IsNullOrEmpty(textboxmvc))
{
student = student.Where(s => s.FirstName.ToUpper().Contains(textboxmvc.ToUpper())
|| s.LastName.ToUpper().Contains(textboxmvc.ToUpper())||s.Id==int.Parse(textboxmvc));
}
return View(student);
}
it shows this problem:
Server Error in '/' Application.
LINQ to Entities does not recognize the method 'Int32 Parse(System.String)' method, and this method cannot be translated into a store expression.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NotSupportedException: LINQ to Entities does not recognize the method 'Int32 Parse(System.String)' method, and this method cannot be translated into a store expression.
Source Error:
Line 42: </tr>
Line 43:
Line 44: <% foreach (var item in Model) { %>
Line 45: <tr>
Line 46:
Source File: d:\aimen\Projects\Schoo_Project\Schoo_Project\Views\Students\Search.aspx Line: 44