title: uses First/FirstOrDefault/Last/LastOrDefault operation without OrderBy and filter which may lead to unpredictable results
body: <p>I have a linq query which gave me the warning but it still works. I want to get rid of the warning.</p>
  <pre><code>uses First/FirstOrDefault/Last/LastOrDefault operation without OrderBy and filter which may lead to unpredictable results.
  </code></pre>
  <p>The linq query is</p>
  <pre><code>var list = (from u in _db.user
          join r in _db.resource on u.userId equals r.userId
          join t in _db.team on u.bossId equals t.bossId
          where r.pid == pid
          select new MyDto
          {
              pid = pid,
              userId = u.userId,
              teamId = t.teamId,
              name = t.name
          }).GroupBy(d =&gt; d.userId).Select(x =&gt; x.First()).OrderBy(y =&gt; y.userId).ToList();
  </code></pre>
  <p>I use EntityFramework Core 2.1</p>
  <p><strong>UPDATE:</strong></p>
  <p>I changed the code by the comments.</p>
  <pre><code>var list = (from u in _db.user
          join r in _db.resource on u.userId equals r.userId
          join t in _db.team on u.bossId equals t.bossId
          where r.pid == pid
          select new MyDto
          {
              pid = pid,
              userId = u.userId,
              teamId = t.teamId,
              name = t.name
          })
          .GroupBy(d =&gt; d.userId)
          .Select(x =&gt; x.OrderBy(y =&gt; y.userId)
          .First())
          .ToList();
  </code></pre>
  <p>Then there is a different warning.</p>
  <blockquote>
  <p>The LINQ expression 'GroupBy([user].userId, new MyDto() {pid =
  Convert(_8_locals1_pid_2, Int16), userId = [user].UserId, .....) could
  not be translated and will be evaluated locally.</p>
  </blockquote>