asp.net mvc - Elegant way to model multiple reviewers for a form in MVC with Entity First -


how model data on form there multiple reviewers. create multiple collections or use array , adding type field? or else? when used multiple instances commented out, created multiple mainform_id in employee table.

//main form

public class mainform {     public int id { get; set; }      public virtual icollection<employee[]> employeearray { get; set; }     //public virtual icollection<employee> employeereviewing { get; set; }     //public virtual icollection<employee> employeesupervisor { get; set; }     //public virtual icollection<employee> employeemanager { get; set; }     //public virtual icollection<employee> employeebigboss { get; set; }  } 

//employee

public class employee {     public int id { get; set; }     public int programentryid { get; set; }     public int reviewertypeid { get; set; }     public virtual mainform mainform { get; set; }     public virtual reviewertype reviewertype { get; set; } } 

i not store collections directly on mainform class. instead have new class houses both employeeid , formid.

///form

public class mainform {     [key]     public int id { get; set; } } 

///employee

public class employee {     [key]     public int id { get; set; }     [foreignkey("employeetype")]     public int employeetypeid {get;set;}  } 

///employeetype

public class employee {     [key]     public int id { get; set; } } 

///employeereview

public class employeereview {     [key]     public int id { get; set; }     [foreignkey("employee")]     public int employeeid { get; set; }     [foreignkey("mainform ")]     public int mainformid{ get; set; }      public virtual employee employee { get; set; }     public virtual mainform mainform { get; set; } } 

then query form such that:

var reviews = employeereview.where(x => x.employee.employeetypeid == (int)enum.employee.employeesupervisor) 

reviews @ point grant access required form , employees of said type reviewed form.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -