множественный выбор для класса, который имеет 3 отношения «многие ко многим» с 3 таблицами - PullRequest
0 голосов
/ 11 января 2019

У меня 4 класса, 3 из них имеют отношения «многие ко многим» с основным человеком. Как я могу создать выпадающий список с несколькими вариантами для Person, чтобы выбрать из списка книг, классов и конференций? у человека в классе есть Список книг, список классов и список конференций, поскольку у человека может быть более одного из каждого из этих классов. То же самое относится и к книгам, классам и конференциям. У каждого из этих классов есть список людей, поскольку в книге может быть несколько авторов, в классе может быть несколько инструкторов, а в конференции может быть несколько участников. Я не уверен, как это сделать и связать таблицы друг с другом. Любая помощь будет высоко ценится. Сначала я использую код структуры сущности.

Вот мои занятия:

public class Workshop
{
    public Workshop()
    {
        Customers = new HashSet<Customer>();
    }

    [Key]
    public int WorkshopID { get; set; }
    public string Title { get; set; }
    public string Description { get; set; }
    public Session sessions { get; set; }

    public virtual ICollection<Customer> Customers { get; set; }
}

public enum Session
{
    NewWorkshopPanels,
    Workshops,
    PanelSessions
}


  public class Paper
   {
       public Paper()
       {
        Customers = new HashSet<Customer>();            
    }


    [Key]
    public int PaperID { get; set; }

    [DisplayName("Short Title")]
    public string ShortTitle { get; set; }

    [DisplayName("Paper Title")]
    public string Title { get; set; }

    [DisplayName("Description")]
    public string Description { get; set; }

    [DisplayName("Published Date")]
    [DataType(DataType.Date)]
    [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]        
    public DateTime? PublishedDate { get; set; }

    [DisplayName("Date Created")]
    [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]        
    [DataType(DataType.Date)]
    public DateTime? CreateDate { get; set; }

    [DisplayName("Due Date")]
    [DataType(DataType.Date)]
    [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]        
    public DateTime? DueDate { get; set; }

    [DisplayName("Image Title")]
    public string imgTitle { get; set; }

    [DisplayName("Image")]
    public string imgPath { get; set; }

    [NotMapped]
    public HttpPostedFileBase ImageFile { get; set; }

    public virtual ICollection<Customer> Customers { get; set; }
    public virtual ICollection<FileUsed> Files { get; set; }
}


public class Conference
    {
        public Conference()
        {
        Customers = new HashSet<Customer>();
    }

    [Key]
    public int ConferenceID { get; set; }
    public string Title { get; set; }
    public string Description { get; set; }

    [DisplayName("Start Date")]
    [DataType(DataType.Date)]        
    [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]       
    public DateTime? StartDate { get; set; }

    [DataType(DataType.Date)]
    [DisplayFormat(DataFormatString = "{0:dd MMM yyyy}")]        
    public DateTime? EndDate { get; set; }

    [DataType(DataType.Time)]
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:hh\\:mm}")]
    public TimeSpan? StartTime { get; set; }

    [DataType(DataType.Time)]
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:hh\\:mm}")]
    public TimeSpan? EndTime { get; set; }

    public virtual ICollection<Customer> Customers { get; set; }
    public virtual ICollection<FileUsed> Files { get; set; }
}

 public class Customer
    {
        public Customer()
        {
        paper = new HashSet<Paper>();
        workshop = new HashSet<Workshop>();
        conference = new HashSet<Conference>();
    }


    [Key]
    public int CustomerID { get; set; }
    [DisplayName("First Name")]
    public string FirstMidName { get; set; }

    [DisplayName("Last Name")]
    public string LastName { get; set; }

    [DisplayName("Short Title")]
    public string ShortTitle { get; set; }

    [DisplayName("Title")]
    public string Title { get; set; }

    [DisplayName("Biography")]
    public string Bio { get; set; }

    public string Company { get; set; }

    public bool? IsHallFame { get; set; }


    [DisplayName("Hall of Fame Date")]
    [DataType(DataType.Date)]
    [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]        
    public DateTime? HallOfFameDate { get; set; }
    public bool? IsInstructor { get; set; }
    public bool? IsTechnicalCommittee { get; set; }
    public bool? IsAuthor { get; set; }

    [DisplayName("Full Name")]
    public string FullName
    {
        get { return FirstMidName+"  " +LastName; }
    }

    //public int? conferenceID { get; set; }
    //public int? PaperID { get; set; }
    //public int? WorkshopID { get; set; }

    public CustomerRole customerRole { get; set; }

    //public virtual Conference conference { get; set; }
    //public virtual Workshop workshop { get; set; }
    //public virtual Paper paper { get; set; }


    public virtual ICollection<Conference> conference { get; set; }
    public virtual ICollection<Workshop> workshop { get; set; }
    public virtual ICollection<Paper> paper { get; set; }


    public virtual ICollection<FileUsed> Files { get; set; }


}

public enum CustomerRole
{
    Speaker = 1,
    Attendant = 2
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...