我正在寻找帮助连接3个表,但从最后一个表,我只需要最后一个条目的日期为余额。我尝试OrderByDescending为GLBalances表。
var list = await (from ba in _context.BankAccounts
join bnk in _context.Banks on ba.BankId equals bnk.ID
join glB in _context.GLBalances on ba.BankGL equals glB.GLAccountGuid
select new BankAccountDto()
{
BankId = ba.BankId,
AccountNumber = ba.AccountNumber,
BankName = bnk.BankName,
Notes = ba.Notes,
Description = ba.Description,
Balance = (decimal)glB.ClosingBalance // ***need the last entry by date
}).ToListAsync();
1条答案
按热度按时间nqwrtyyt1#
要按日期获取
GLBalances
表的最后一个条目,可以使用OrderByDescending
方法按日期降序对GLBalances
记录进行排序。您可以修改查询以实现此目的:
更新了。试试这个,