/// <summary> /// /// </summary> /// <param name="collection"></param> /// <param name="filter"></param> /// <param name="parameters"></param> /// <returns></returns> public IEnumerable EnumerableFilter( object collection, string filter, QueryParameters parameters ) { string[ ] concreteFilters = QueryTranslator.ConcreteQueries( filter, factory ); FilterTranslator[ ] filters = new FilterTranslator[concreteFilters.Length]; for( int i = 0; i < concreteFilters.Length; i++ ) { filters[ i ] = GetFilterTranslator( collection, concreteFilters[ i ], parameters, true ); } if( filters.Length == 0 ) { return new ArrayList( 0 ); } IEnumerable result = null; IEnumerable[ ] results = null; bool many = filters.Length > 1; if( many ) { results = new IEnumerable[filters.Length]; } // execute the queries and return all results as a single enumerable for( int i = 0; i < filters.Length; i++ ) { try { result = filters[ i ].GetEnumerable( parameters, this ); } catch( Exception e ) { throw new ADOException( "could not execute query", e ); } if( many ) { results[ i ] = result; } } return many ? new JoinedEnumerable( results ) : result; }
private FilterTranslator CreateFilterTranslator( string filterString, FilterCacheKey cacheKey ) { FilterTranslator filter = new FilterTranslator( filterString ); Put( cacheKey, filter ); return filter; }
/// <summary> /// /// </summary> /// <param name="collection"></param> /// <param name="filter"></param> /// <param name="parameters"></param> /// <returns></returns> public IList Filter( object collection, string filter, QueryParameters parameters ) { string[ ] concreteFilters = QueryTranslator.ConcreteQueries( filter, factory ); FilterTranslator[ ] filters = new FilterTranslator[concreteFilters.Length]; for( int i = 0; i < concreteFilters.Length; i++ ) { filters[ i ] = GetFilterTranslator( collection, concreteFilters[ i ], parameters, false ); } dontFlushFromFind++; // stops flush being called multiple times if this method is recursively called IList results = new ArrayList(); try { for( int i = 0; i < concreteFilters.Length; i++ ) { IList currentResults; try { currentResults = filters[ i ].List( this, parameters ); } catch( Exception e ) { throw new ADOException( "could not execute query", e ); } foreach( object res in results ) { currentResults.Add( res ); } results = currentResults; } } finally { dontFlushFromFind--; } return results; }