我在创建linq语句时遇到了麻烦,该语句会抓取指定的startdate之前发生的最近事务。想知道是否有人可以帮助我。抓取最近的交易/记录
例如startdate是1月20日。
Id LoanId TransactionDate InterestDate Balance
1 5 January 5 January 3 5000
1 5 January 30 January 5 10000
2 5 January 22 January 22 4000
3 6 January 3 January 1 2000
我应该有以下
Id LoanId TransactionDate InterestDate Balance
1 5 January 5 January 3 5000
3 6 January 3 January 1 2000
我无法通过分组,抓住正确的值的列表。
var transactions = ctx.Transactions.Where(x => x.Date <= startDate)
.GroupBy(x => x.LoanId)
.Select(x => new TransactionDTO
{
LoanId = ...
TransactionDate = ...
InterestDate = ....
Balance = ...
});
让我们来看看您遇到那就麻烦查询请。这是Linq到SQL还是Linq到对象或...? TransactionDate是一个DateTime对象吗? –