title: Alternative for ElementAtOrDefault
body: <p>My business logic is following. I have <code>CustomerEvents</code> table. The table contains <code>CreatedAt</code> column and <code>CustomerId</code> column. I need to retrieve last and previous event for particular customer. About the last I have not problems. But what to do with the previous? I have tried <code>ElementAtOrDefault</code>. But it does not work. I will show you my code: </p>
  
  <pre><code>PrevReDepDate = context.CustomerEvents.Where(y
          =&gt; y.Customer.CustomerId == 123 &amp;&amp; y.EventType == "deposit" &amp;&amp; y.Again == true)
      .Select(y =&gt; y.CreatedAt).OrderByDescending(y =&gt; y)
      .ElementAtOrDefault(1),
  </code></pre>
  
  <p>It does not work. It seems to me, it's happening because EF is not able to execute it on the database server side. Here is exception text: </p>
  
  <blockquote>
    <p>System.InvalidOperationException: Processing of the LINQ expression 'DbSet
        .ElementAtOrDefault(__p_0)' by 'NavigationExpandingExpressionVisitor' failed. This may indicate either a bug or a limitation in EF Core. See <a href="https://go.microsoft.com/fwlink/?linkid=2101433" rel="nofollow noreferrer">https://go.microsoft.com/fwlink/?linkid=2101433</a> for more detailed information.
       at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)</p>
  </blockquote>
  
  <p>Am I right? If yes, any alternatives for getting previous element like with the help of <code>ElementAtOrDefault</code>?</p>