c# - Should I use a collection of Users or user in a certain class inMVC4 -
i have department filled users in eg mark in hr department , james in hr department etc
i'm wondering use
public virtual icollection users { get; set; }
or
public virtual user user { get; set; }
for department , depot classes same?
public class department { public int departmentid { get; set; } [stringlength(50, minimumlength = 3)] public string name { get; set; } [display(name = "administrator")] public int userid { get; set; } public virtual icollection<user> users { get; set; } }
can check if did these few lines correctly in user class(you can reference below)
public virtual icollection<ticket> tickets { get; set; } <-users can have collection of tickets because can open many tickets want. public virtual administrator administrator { get; set; } <- 1 user can 1 type of admin @ time public virtual department department { get; set; } <- 1 user can @ 1 department in @ time public virtual depot depot { get; set; } <- 1 user can @ 1 depot time
user class
public class user { public int userid { get; set; } [stringlength(50, minimumlength = 1)] public string lastname { get; set; } [stringlength(50, minimumlength = 1, errormessage = "first name cannot longer 50 characters.")] [column("firstname")] public string firstmidname { get; set; } [datatype(datatype.date)] [displayformat(dataformatstring = "{0:yyyy-mm-dd}", applyformatineditmode = true)] public datetime enrollmentdate { get; set; } public int depotid { get; set; } public int departmentid { get; set; } public int ticketid { get; set; } public string fullname { { return lastname + ", " + firstmidname; } } public virtual icollection<ticket> tickets { get; set; } public virtual administrator administrator { get; set; } public virtual department department { get; set; } public virtual depot depot { get; set; } } }
yeah should use department because it'll contain collection of users.
Comments
Post a Comment