title: How to write orderBy query with raw SQL in EfCore?
body: <p>I have EfCore query:</p>
  <pre><code> return await _context.Rubrics
                  .AsNoTracking()
                  .Where(i =&gt; i.IsApproved == true)
                  .Include(i =&gt; i.EdDraft)
                  .Include(i =&gt; i.Rubric)
                  .ThenInclude(i =&gt; i.Title)
                  .Where(i =&gt; i.EdDraft.AccountId == accountId)
                  .OrderBy(i =&gt; i.Path)
                  .ToListAsync();
  </code></pre>
  <p>i.Path is string like &quot;1-5-3&quot;, &quot;1-5-3-2&quot;, &quot;9-18-12&quot; and etc...
  I have to order by char - the first character, for example order by &quot;1-&quot;, &quot;9-&quot; and etc.</p>
  <p>I don't want rewrite all query with raw <a href="https://docs.microsoft.com/en-us/ef/core/querying/raw-sql" rel="nofollow noreferrer">sql</a>.
  In Laravel I do:</p>
  <pre><code>orderBy(DB::raw(...sql))
  </code></pre>
  <p>but in EfCore I can't find a solution.</p>
  <p>I know how I can rewrite on client side (.AsEnumerable), but I need write query on server side.</p>
  <p>Query has to order by first character in string.</p>