Why EF can’t translate Int32.Parse in where condition section?
For example below code has error :
var query = (from list in dbContext.Packages
where list.Id == Int32.Parse(Request["Id"].ToString())
select list).FirstOrDefault();
I solved this problem :
Int32 ID = Int32.Parse(Request["Id"].ToString());
var query = (from list in dbContext.Packages
where list.Id == ID
select list).FirstOrDefault();
Because the query is simply an Expression that gets translated into SQL.
EF doens’t know how to translate
Int32.Parseinto an equivalent SQL statement, so it fails.