유사를 IEnumerable/컬렉션 속성을 사용하여 사용자 ID를 연장 : How to extend available properties of User.Identity방법이 질문에
I 사용자가 로그인 내 사용자와 연관이있는 부서를로드하고자합니다. 나는이 같은 ApplicationUser
클래스에 속성을 추가 할 것 같은데요 :
public class ApplicationUser : IdentityUser<Guid, GuidUserLogin, GuidUserRole, GuidUserClaim>
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(ApplicationUserManager manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
return userIdentity;
}
public IEnumerable<Department> Departments { get; set; }
}
내 문제는 내 컨트롤러에서 나중에 속성에 액세스 할 어떻게 다음 컬렉션을 채우고 것 인 방법 /입니다. 내가 이해하는 바에 따르면, 클레임은 단순한 유형 (예 : ID)에서 사용할 수 있지만 컬렉션과 함께 사용할 수 있습니까?
일단이 속성이로드되면 사용자에 대한 정보가 필요할 때마다 데이터베이스를 치지 않고 컬렉션을 쿼리 할 수 있다고 가정합니다.
도움을 주시면 감사하겠습니다.
아마도 컬렉션을 저장하는 도메인 엔티티가 상기 ApplicationUser의 ID가 관계를 설정하는 참조 :
여기서,는 코드 1 엔티티 프레임 워크를 사용하는 가정은 예시입니까? – Esen
ApplicationUser 클래스의 생성자에서? – daniel