挣扎新手:(问题与登录
实体没有获取用户..
登录控制器
[HttpPost]
public ActionResult LoginForm(string user_NA, string user_pwd)
{
User u = new User();
u.LogIn(user_NA, user_pwd);
return RedirectToAction("Index");
}
登录型号
public bool LogIn(string userID, string password)
{
using (Entity.xcLEntities en = new xcLEntities())
{
try
{
var user = en.Users.SingleOrDefault(x => x.LoginID == userID && x.PasswordHash == this.SetPassword(password));
if (user != null && password != null)
{
return true;
}
else
{
return false;
}
}
catch (Exception e)
{
throw e;
}
}
}
异常shoing
An exception of type 'System.NotSupportedException' occurred in AML.Web.dll but was not handled in user code
Additional information: LINQ to Entities does not recognize the method 'System.String SetPassword(System.String)' method, and this method cannot be translated into a store expression.
如何使用ID获取用户? – JRU
你确定用户在那?如果你得到所有的用户,你是否看到了用户正在测试的'LoginID'? –
@AndreiV你是否指一个实体? – JRU