1

我需要得到所有bank的地方BankBranches cityId = filter.CityId > 0

代码:

 banks = from bank in banks
            where bank.BankBranches.Where(y => y.CityId == filter.CityId).Count() > 0
            select bank;
    var list = banks.ToList();

错误:

对于类型“System.Linq.IQueryable”[Model.Entities.BankBranch],不允许从“Model.Entities.BankBranch”访问成员“Int32 CityId”。

4

2 回答 2

2
 banks = from bank in banks.Include(p=>p.BankBranches)
            where bank.BankBranches.Where(y => y.CityId == filter.CityId).Count() > 0
            select bank;
    var list = banks.ToList();
于 2012-04-18T07:08:12.727 回答
0
banks = from bank in banks
        join bankBranche in m_banksRepository.BankBranches on bank.Id equals bankBranche.BankId
        where bankBranche.CityId == filter.CityId
        select bank;
于 2012-04-18T11:06:35.650 回答