Link to home
Start Free TrialLog in
Avatar of Natavia Finnie
Natavia FinnieFlag for United States of America

asked on

MVC Code first data design

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

Avatar of Duy Pham
Duy Pham
Flag of Viet Nam image

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.
Avatar of Natavia Finnie

ASKER

I need help with the navigational properties
ASKER CERTIFIED SOLUTION
Avatar of Duy Pham
Duy Pham
Flag of Viet Nam image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you!!