Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In order to answer this properly, I need to know if Application and Person are directly related (i.e. does Person have many Applications)? From reading your post, I'm assuming that they are because Application seems to have a foreign key to person. </p> <p>If so, then you could create a custom PersonModel which will be populated by the fields you need from the different entities like this:</p> <pre><code>class PersonModel { string Name { get; set; } string Surname { get; set; } List&lt;int&gt; Scores { get; set; } List&lt;int&gt; Positions { get; set; } } </code></pre> <p>Then to populate it, you'd do the following:</p> <pre><code>// Select the correct person based on Name and Surname inputs var person = dataContext.Persons.Where(p =&gt; p.Name.Contains("firstname") || p.Name.Contains("surname")).FirstOrDefault(); // Get the first person we find (note, there may be many - do you need to account for this?) if (person != null) { var scores = new List&lt;int&gt;(); var positions = new List&lt;int&gt;(); scores.AddRange(person.Applications.Select(i =&gt; i.Score); positions.AddRange(person.Applications.Select(i =&gt; i.Position); var personModel = new PersonModel { Name = person.Name, Surname = person.Surname, Scores = scores, Positions = positions }; } </code></pre> <p>Because of your relationship between Person and Application, where a person can have many applications, I've had to account for the possibility of there being many scores and positions (hence the List). </p> <p>Also note that I've used lambda expressions instead of plain linqToSql for simple selecting so that you can visualise easily what's going on. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload