Solved

How do you do a one to many list in .NET CORE?

Posted on 2017-01-25
2
36 Views
Last Modified: 2017-02-07
My task is pretty straightforward, but I don't know how to pull it off.

I need to run a list where I'm grabbing all of the individuals listed in one table and then all the activities those individuals do from another table. So, it looks like this:

table_1.individual_one
     table.2.individual_one_activity
     table.2.individual_one_activity
table_1.individual_two
    table.2.individual_two_activity
    table.2.individual_two_activity

It's your basic one to many relationship and while I know how to do it in another language, I'm new to .NET, hence the basic nature of my question.

The good news is that I'm working in the context of an app that's pretty verbose and is working very well, so I want to hope that I can just mimic some of what's already going on. I think I've found an example, but I would still like some input.

Here's what appears to be a basic list:

 public class DesignPro : Entity
    {
        public string DesignProID { get; set; }
        public List<DesignProD> DesignProfessionalD { get; set; }
    }

Here's what I'm thinking is something similar to what I need, but I don't completely understand it...

 public class DesignProfessionalDiscipline : Entity
    {
        public int DesignProfessionalDId { get; set; }
        public string DesignProLk { get; set; }
        public DesignProfessional DesignProfessional { get; set; }
        public string DisciplineLk { get; set; }
        public Discipline Discipline { get; set; }
        public List<DrawingDesignProfessionalDiscipline> DrawingDesignProfessionalDisciplines { get; set; }
    }

I see "DisciplineDiscipline" and I'm wondering if that's an embedded list of sorts.

Can someone point me in the right direction?
0
Comment
Question by:brucegust
2 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 41979898
To your statement, "I see "DisciplineDiscipline" and I'm wondering if that's an embedded list of sorts.", no that is not a list it is a single instance of Discipline.
0
 

Author Closing Comment

by:brucegust
ID: 41998837
This has since been resolved, Fernando, but thanks for weighing in!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question