Linq to Entity Query takes more than 2 minutes to execute
<p>I am trying to perform the following query using LINQ to Entity and have a performance issue. It takes about 2-3 mins for the result to return. I need suggestions on how we can improve the performance of these queries</p>

<p>This is the method that I am using to bring the total number of orders between certain dates. The data is split between two tables here. I need to get the transaction numbers from one table and then using these transactions I am pulling out the orders and summing them up but the query is too slow for certain criteria where I have around 10k+ records returned in the first query.</p>

<pre><code>public int GetOrderQuantity(List&lt;int&gt; TransactionNumbers, DateTime FromDate, DateTime ToDate)
{
    List&lt;int&gt; transactions = _context.RP_PART_TRANSACTIONS.Where(trd =&gt; TransactionNumbers.Contains(trd.TRANSACTION_NUMBER) &amp;&amp; trd.TRANSACTION_DATE &gt;= FromDate &amp;&amp; trd.TRANSACTION_DATE &lt;= ToDate).Select(tr =&gt; tr.TRANSACTION_NUMBER).ToList();

    return _context.RP_PART_TRANSACTION_DETAILS.Where(trd =&gt; transactions.Contains(trd.TRANSACTION_NUMBER)).Select(tr =&gt; tr.PART_QTY).ToList().Sum();
}
</code></pre>