代码之家  ›  专栏  ›  技术社区  ›  Eran Betzalel

如何将以下SQL查询实现为linq to entities查询?

  •  -1
  • Eran Betzalel  · 技术社区  · 15 年前

    如何将以下SQL查询实现为linq to entities查询?

    select *, MIN(QueuedDate)
    from pcm_transactions
    where QueuedDate IS NOT NULL And ExecutionDate IS NULL
    group by SimId
    

    编辑:

    //  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();
    
    1 回复  |  直到 15 年前
        1
  •  0
  •   Eran Betzalel    14 年前

    一个问题是,SQL从一开始就无效;您必须这样做 等等),所以“选择*”根本没有意义。你有样本数据吗

    引自威尔的评论