私はこのコードを持っています:
UserProfileを(対応するCRUD(Controlers + Views)を使用して)編集すると、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; }
}
私が欲しいもの:もっとシンプルなものが欲しいのですが、なんとかできません:
モデル(またはコントローラー)で性別タイプをハードコーディング(男性/女性)したい。データベースにはありません。データベースは必要ありませんが、「UserProfile」でレコードを作成または更新するたびに、「male/female」オプションを使用してドロップダウンを視覚化するだけです。
それを手伝ってくれませんか。