掙扎新手:(問題與登錄
實體沒有獲取用戶..
登錄控制器
[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