Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>how best to integrate a method which contains a query that queries multiple entities into the repository. </p> </blockquote> <p>Considering the relationship between <code>User</code> and <code>Journey</code>, you should decide which entity owns the relationship and use <code>Aggregate Root</code> to fetch data. </p> <p>The description of <code>Aggregate Root</code> at <a href="https://stackoverflow.com/questions/1958621/whats-an-aggregate-root">What&#39;s an Aggregate Root?</a> would be helpful.</p> <p><strong>Update:</strong></p> <p>Entities</p> <pre><code>public class User { public User() { this.Journeys = new List&lt;Journey&gt;(); } public int Id { get; set; } public virtual IList&lt;Journey&gt; Journeys { get; set; } } public class Journey { public Journey() { this.Users = new List&lt;User&gt;(); } public int Id { get; set; } public virtual IList&lt;User&gt; Users { get; set; } } </code></pre> <p>Repositiories</p> <pre><code>public class UserRepository { public IList&lt;User&gt; GetAllUsersWithJourneys() { //Fetch all Users; Include Journeys } } public class JourneyRepository { public IList&lt;Journey&gt; GetAllJourneysWithUsers() { //Fetch all journeys; Include Users } } </code></pre> <p>ViewModel</p> <pre><code>public class UserJourneyViewModel { public int UserId { get; set; } public int JourneyId { get; set; } } </code></pre> <p>Controller's Action</p> <pre><code>public ViewResult Search() { // Use UserRepository or JourneyRepository to make a list of // UserJourneyViewModel that provides appropriate data for the view. } </code></pre>
    singulars
    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. VO
      singulars
      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