2012-04-28 56 views
0

为什么IQueryable在Where子句中执行?

public IQueryable<Guid> AccessibleCities 
{ 
    get 
    { 
     return CityRepository 
      .FindAll(a => <CONDITIONS>); 
    } 
} 

CityRepository.FindAll作为实施:

public virtual IQueryable<TLookup> FindAll(Expression<Func<TLookup, bool>> predicate) 
{ 
    return DataContext.GetSet<TLookup>().Where(predicate); 
} 

而且我把这种

anotherRepository 
    .FindAll(a => AccessibleCities.Any(b => ANOTHER CONDITION)); 

当我把最后一个,它生成的两个查询,而不是添加AccessibleCities为查询。

请帮我:)

+0

只是简单的条件: CityRepository.FindAll(a => a.Id =='GUID'); – Sergey 2012-04-28 13:45:52

+0

的FindAll它是一样的凡在我的情况下 – Sergey 2012-04-28 13:46:39

+0

公共虚拟的IQueryable 的FindAll(表达式>谓词) { 返回DataContext.GetSet ()。凡(谓词); } – Sergey 2012-04-28 13:47:04

回答

1

您的最终查询只是不这样工作;它默认不会连接。

尝试PredicateBuilder类。这看起来应该适用于你想要达到的目标。