We help IT Professionals succeed at work.

MVC Code first data design

Natavia Finnie
on
89 Views
Last Modified: 2018-12-14
I am trying to create joins between 3 tables using MVC code first approach. My main table is the Request table. I need to be able to join these tables.  The requirements is going to build a multi check list box where multiple requirements may be checked. A request may have multiple requirements... I need help with the navigational properties

public partial class Request
    {
        public int ID { get; set; }

        [StringLength(10)]
        [Display(Name = "User Name")]
        public string UserName { get; set; }

       public DateTime? RequestDate { get; set; }

        public int? RequestRequirementId { get; set; }
    }

Open in new window

==================================================================================
public partial class Requirement
    {
        public int ID { get; set; }

        [Required]
        [StringLength(100)]
        public string Description { get; set; }
    }

Open in new window

===================================================================================
public partial class RequestRequirement
    {  
        public int ID { get; set; }
       
        public int RequestId { get; set; }
        
        public int RequirementId { get; set; }

        public virtual Requirement Requirement { get; set; }

        public virtual Request Request { get; set; }
    }

Open in new window

Comment
Watch Question

Duy PhamFreelance IT Consultant
CERTIFIED EXPERT

Commented:
I think you could use Linq Join in this case. See reference here: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/join-clause.
Natavia FinnieSenior Analyst Technical Focus Applications

Author

Commented:
I need help with the navigational properties
Freelance IT Consultant
CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Natavia FinnieSenior Analyst Technical Focus Applications

Author

Commented:
Thank you!!