나는 [key]
속성을 가진 ViewModel을 가지고 있는데 그 뷰 모델의 인스턴스에서 가져오고 싶습니다.ViewModel에서 [key] 속성 가져 오기
내 코드
class AddressViewModel
{
[Key]
[ScaffoldColumn(false)]
public int UserID { get; set; } // Foreignkey to UserViewModel
}
// ... somewhere else i do:
var addressModel = new AddressViewModel();
addressModel.HowToGetTheKey..??
그래서 내가 뷰 모델에서 UserID
(이 경우)를 취득하기 위해 필요한이 (가상 모델)과 같이 보입니다. 내가 어떻게 할 수 있니?
. [이 질문] (http://stackoverflow.com/questions/390594/c-sharp-setting-property-values-through-reflection-withattribute)에서는 주제를 다룹니다. –
'KeyAttribute'가 여러 속성에 주석을 달면 어떤 일이 일어나는지 생각해 봐야합니다. – Jon