var list = new List<ListCreaditInBankView>();
var banktemp = m_banksRepository.Banks;
foreach (Bank bank in banktemp)
{
var bankbranchtemp = m_banksRepository.BankBranches.Where(x => x.BankId == bank.Id);
foreach (BankBranch bankBranch in bankbranchtemp)
{
var creditortemp = m_creditorsRepository.Creditors.Where(x => x.BankBranchId == bankBranch.Id);
list.Add(new ListCreaditInBankView(){Bank = bank, Creditors = creditortemp});
}
}
我需要得到List<ListCreaditInBankView>
没有这些周期。
我试过了,但它只得到一个Creditors
var lists = (from bank in banksTemp
let creditorBank = m_creditorsRepository.GetCreditorBank(bank.BankBranches.Select(x => x.Id).ToList())
select new ListCreaditInBankView() {Bank = bank, Creditors = creditorBank}).ToList();