【发布时间】:2010-10-17 06:03:19
【问题描述】:
这曾经对我有用,然后失败了。我只想返回那些包含所有过滤器的项目,而不是像现在这样至少返回一个过滤器。这里有什么问题?
private IQueryable<IndexItem> FilteredIndex (IQueryable<IndexItem> index, IEnumerable<string> filters)
{
var filteredIndex= from f in filters.AsQueryable()
where f.Length>0
from i in index
where i.FilterNames.Contains(f)
select i;
return filteredIndex;
}
【问题讨论】:
-
您使用的是哪个 LINQ 提供程序?我假设它不是 LINQ to Objects,基于 IQueryable 的使用。
-
我可以为 LINQ to Objects 提供一个非常优雅的解决方案,但我不确定它是否适合您。让我听听。
标签: c# linq sorting collections