(데이터를 생성하고 업데이트하는)이 코드가 (당신이 사용자 프로필을 편집 할 때하드 코딩 드롭 다운
이 (해당 CRUD와 (Controlers + 조회수)) 당신이 SexType에 대한 드롭 다운을 볼 수 있습니다 당신이 다른 CRUD로도 수정할 수 있음) SexType 테이블에 해당합니다.
public class UserProfile{
public int Id { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public int SexTypeId { get; set; }
public virtual SexType SexType { get; set; }
public class SexType
{
public int SexTypeId { get; set; }
public string SexTypeDescription { get; set; }
public virtual ICollection<UserProfile> UserProfiles { get; set; }
}
public class UserProfileDBContext : DbContext //This creates the database according to the model
{
public DbSet<UserProfile> UserProfiles { get; set; }
public DbSet<SexType> SexType { get; set; }
}
내가 원하는 것은 : 나는 간단한 일을 원하지만 내가 그것을 할 관리 할 수 없습니다 :
내가있는 sextype 내 모델 (남성/여성) 하드 코딩 할 (또는 제어 장치). 데이터베이스에 없습니다. "UserProfile"에서 레코드를 만들거나 업데이트 할 때마다 데이터베이스가 필요 없지만 "male/female"옵션을 사용하여 드롭 다운을 시각화합니다.
도와 주실 수 있습니까?
cshtml은 어떻게 생겼습니까? –
성별 대신 성별을 묻는 이유는 무엇입니까? – CodesInChaos