LINQ to Entities无法识别方法' Int32 ToInt32(System.String)'方法。 MVC

时间:2016-02-26 07:36:31

标签: asp.net-mvc linq asp.net-mvc-4 entity-framework-4

LINQ to Entities无法识别方法' Int32 ToInt32(System.String)'方法

System.Web.Security.MembershipUser mu = System.Web.Security.Membership.GetUser();

string ID = mu.ProviderUserKey.ToString();

if(db.resume.Where(x => x.employeeID ==Convert.ToInt32(ID)).Count() == 0)

1 个答案:

答案 0 :(得分:1)

如异常消息中所述,表达式中不支持Convert.ToInt32。只需将其移出表达式:

System.Web.Security.MembershipUser mu = System.Web.Security.Membership.GetUser();

string ID  = mu.ProviderUserKey.ToString();
int    IID = Convert.ToInt32(ID);

if( db.resume.Where(x => x.employeeID == IID).Count() == 0 )