asp.net mvc - Foreign Keys on fields with different name -
i have created table called tbgeneraloptions holds default answers questions in application. options yes, no, n/a values of 1,2,3 respectively.
public class tbgeneraloption { public int tbgeneraloptionid { get; set; } [required(errormessage = "please enter option")] [display(name = "option")] public string optionname { get; set; } public virtual icollection<tbfamilymember> tbfamilymember { get; set; } public virtual icollection<tbfamily> tbfamily { get; set; } }
in tbfamilymember table storing values above options on fields of disability , photopermission.
public class tbfamilymember { [display(name = "family member id")] public int tbfamilymemberid { get; set; } [display(name = "family id")] public int tbfamilyid { get; set; } [required(errormessage = "please select role")] [display(name = "role")] public int tbfamilyroleid { get; set; } [display(name = "firstname")] public string firstname { get; set; } [display(name = "surname")] public string surname { get; set; } [required(errormessage = "please select if family member has disability")] [display(name = "disability")] public int disability { get; set; } [required(errormessage = "please select if family member has given permission photographs")] [display(name = "photo permission")] public int photopermission { get; set; } public virtual tbfamily tbfamily { get; set; } public virtual tbfamilyrole tbfamilyrole { get; set; } public virtual tbgeneraloption tbgeneraloption { get; set; } }
my issue how display optionname stored value in view.
i assuming can make link through foreign keys can done if field names don't match?
based on comments below, don't need tbgeneraloption
@ all, since options per type fixed , static - options not dynamically added. should create options boolean properties on types have options. also, can remove error messages these options, because options not required, definition.
i removed properties tbfamilyid
, tbfamilyroleid
because referencing family , familyrole @ bottom , ids accessible thought there, in case need display them , shouldn't. here updated model family member:
public class tbfamilymember { public int tbfamilymemberid { get; set; } [display(name = "firstname")] public string firstname { get; set; } [display(name = "surname")] public string surname { get; set; } [display(name = "disability")] public bool disability { get; set; } [display(name = "photo permission")] public bool photopermission { get; set; } public virtual tbfamily tbfamily { get; set; } public virtual tbfamilyrole tbfamilyrole { get; set; } }
Comments
Post a Comment