我正在使用下面的代码在我的 winform 应用程序中登录用户
public static Boolean Attempt(String username, String password, bool salted = false)
{
using (InventorySystemEntities context = new InventorySystemEntities(new ConfigurationManager().ConnectionString))
{
password = password.ToMD5(salted);
User = context.Users.SingleOrDefault(u => u.UserName == username
&& u.Password == password && u.IsEnabled == true);
return User != null ? true : false;
}
}
有没有办法在上下文被处理后访问数据?喜欢使用新的上下文?
User test = Auth.Attempt(txtUsername.Text, txtPassword.Text);
//is there a way to access this?
test.UserGroup.Name;