我正在尝试使用以下
过滤检索中的子对象var loanExtractExample = be.LoanCategoryMonitors
.Where(lcm => lcm.LoanNumber == 5000435)
.Include(l => l.Loan)
.Include(le => le.LoanExtracts)
.Select(le => le.LoanExtracts.Borrowers.Where(b => b.BorrowerNum == 1))
.ToList();
但是当我检查实体收藏时,有2个借款人。一个是BorrowerNum 1,一个是BorrowerNum = 3.
我错过了什么能够将借款人减少到正确的借款人?
答案 0 :(得分:0)
借款人的选择我相信会将借款人退回贷款类别监控器,其中监控器有一个ID为1的借款人。我相信你所寻找的是:
create_table :products do |table|
table.string :name
end
由于您没有检索贷款类别监视器,因此不需要包含,但您可能希望为返回的借用者的子引用添加任何.Include()语句。 (在var matchingBorrowers = be.LoanCategoryMonitors
.Where(lcm => lcm.LoanNumber == 5000435)
.SelectMany(le => le.LoanExtracts.Borrowers) // Borrowers for loan extracts against loan 5000435...
.Where(b => b.BorrowerNum == 1)) // Of those borrowers, those with BorrowerNum = 1.
.ToList();
之后)