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

C#Microsoft SQL Server

Avatar of undefined
Last Comment
Natavia Finnie

8/22/2022 - Mon
Duy Pham

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 Finnie

ASKER
I need help with the navigational properties
ASKER CERTIFIED SOLUTION
Duy Pham

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Natavia Finnie

ASKER
Thank you!!
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck