How can I implement the following SQL query as linq to entities query?
select *, MIN(QueuedDate)
from pcm_transactions
where QueuedDate IS NOT NULL And ExecutionDate IS NULL
group by SimId
I spent hours thinking and trying varius methods - hope to find the right answer here.
EDIT:
Here is one of my first tries:
// Get the oldest queued action
var queuedTransactions =
(from t in db.TransactionSet
where t.QueuedDate.HasValue && !t.ExecutionDate.HasValue
group t by new { t.TransactionId, t.QueuedDate } into tr
select new
{
Transaction = db.TransactionSet.First(q => q.TransactionId == tr.Key.TransactionId),
QueuedDate = tr.Min(m => m.QueuedDate)
}).ToList();