ASP.NET 및 엔터티 프레임 워크를 사용하여 로그인 양식을 만들려고합니다. 그리고 다음과 같은 것이 있습니다.
Account account2 = de.Accounts.Find(accountViewModel.Account.Username); if(account2 != null) { if(PasswordHelper.VerifyHash(accountViewModel.Account.Password, "SHA512", account2.Password)) { Session["username"] = account2.Username; return View("intro"); }
찾기 방법은 기본 키로 항목을 검색하는 것임을 알고 있습니다. 내 기본 키는 "AccountID"이지만 "Account"로 요소를 어떻게 찾을 수 있습니까? PLS 도움말 : ((
계좌 번호로 계좌를 찾으 시나요? 계정을 식별하는 데 사용되는 계정 속성에 관계없이 다음 linq가 유용 할 수 있습니다.
using System.Linq;
....
Account account2 = de.Accounts.FirstOrDefault(a => a.Prop == value);
예를 들면 :
Account account2 = de.Accounts.FirstOrDefault(a => a.UserName == accountViewModel.Account.Username);
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다