Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 20, 2012 09:18 AM by DarrellNorton
Member
33 Points
30 Posts
Aug 20, 2012 08:40 AM|LINK
hi friend,
why EF cant 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();
All-Star
86773 Points
9643 Posts
Moderator
MVP
Aug 20, 2012 09:18 AM|LINK
Because Entity Framework has to translate and execute the entire expression in SQL. There is no SQL equivalent to Int32.Parse().
Here is the full list of canonical functions supported by Entity Framework:
http://msdn.microsoft.com/en-us/library/bb738626.aspx
Sirwan Afifi
Member
33 Points
30 Posts
why EF cant translate Int32.Pars(...?
Aug 20, 2012 08:40 AM|LINK
hi friend,
why EF cant 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();DarrellNorto...
All-Star
86773 Points
9643 Posts
Moderator
MVP
Re: why EF cant translate Int32.Pars(...?
Aug 20, 2012 09:18 AM|LINK
Because Entity Framework has to translate and execute the entire expression in SQL. There is no SQL equivalent to Int32.Parse().
Here is the full list of canonical functions supported by Entity Framework:
http://msdn.microsoft.com/en-us/library/bb738626.aspx
Darrell Norton's Blog
Please click "Mark as Answer" if this helped you.