Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>By this: </p> <pre><code> join original in this.NoteDatas on issue.NoteDatas .OrderBy(n =&gt; n.CreatedDate) .Select(n =&gt; n.NoteId) .First() equals original.NoteId </code></pre> <p>you are saying "order by CreatedDate, take first row from the results and check if it equals to NoteId". This is correctly gets rendered to this: </p> <pre><code>INNER JOIN [dbo].[issue_notes] AS [t1] ON (( SELECT TOP (1) [t3].[id] FROM ( SELECT [t2].[id], [t2].[issue_id] FROM [dbo].[issue_notes] AS [t2] ORDER BY [t2].[CreatedDate] ) AS [t3] WHERE [t3].[issue_id] = [t0].[IssueDetailsId] )) = [t1].[id] </code></pre> <p>so <code>t2.id</code> is always same for any outer <code>[t1].[id]</code> but depends on only <code>[t0].[IssueDetailsId]</code></p> <p>Sample: </p> <pre><code> var issues = new Tuple&lt;int, string&gt;[] { new Tuple&lt;int, string&gt;(1, "aaa"), new Tuple&lt;int, string&gt;(2, "bbb") }; var notes = new Tuple&lt;int, DateTime, string&gt;[] { new Tuple&lt;int, DateTime, string&gt;(1, DateTime.Parse("01/01/2001"), "earliest for 1"), new Tuple&lt;int, DateTime, string&gt;(1, DateTime.Parse("02/01/2001"), "middle for 1"), new Tuple&lt;int, DateTime, string&gt;(1, DateTime.Parse("03/01/2001"), "latest for 1"), new Tuple&lt;int, DateTime, string&gt;(2, DateTime.Parse("10/01/2001"), "earliest for 2"), new Tuple&lt;int, DateTime, string&gt;(2, DateTime.Parse("11/01/2001"), "middle for 2"), new Tuple&lt;int, DateTime, string&gt;(2, DateTime.Parse("12/01/2001"), "once more middle for 2"), new Tuple&lt;int, DateTime, string&gt;(2, DateTime.Parse("13/01/2001"), "latest for 2") }; var result = ctx.Set&lt;Parent&gt;().Select(i =&gt; new { i.Id, e = ctx.Set&lt;Child&gt;().Where(c =&gt; c.ParentId == i.Id).OrderBy(c =&gt; c.Name).FirstOrDefault(), l = ctx.Set&lt;Child&gt;().Where(c =&gt; c.ParentId == i.Id).OrderByDescending(c =&gt; c.Name).FirstOrDefault() }); </code></pre>
 

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