使用 LINQ 查找具有相同值的行

find rows with same value using LINQ

上图的问题在于

好的,我想我终于得到了你想要的。

对吗?:将一些 TransactionType 的所有行按 Transholder_ID 分组,然后从每组 select 中获得最大值 Translog_Date 的行,给出您是每个 Transholder_ID 的最新行。一旦你得到了结果,你就可以迭代它来计算你需要的任何东西。

from t in db.TransactionLogDbSet
where where tq.TransactionType == TransactionType.PurchaseOfShares || tq.TransactionType == TransactionType.TransferOfShares || tq.TransactionType == TransactionType.BonusSharesDeclared
group t by t.Transholder_ID into g
select (from t1 in g orderby t1.Translog_Date descending select t1).First();

编辑:只要我们最终得出正确的查询,我将继续编辑我的答案的以下部分。

根据您到目前为止的最后一条评论,您只想 select 具有 TransLog_Date <= 给定 DateTime qualifiedDate.

的所有行
from t in db.TransactionLogDbSet
where t.TransactionLog_Date <= qualifiedDate
select t

是吗?