views:

54

answers:

1

I have a question closely related to the scenario described here: http://stackoverflow.com/questions/293216/linq-to-sql-bug-or-very-strange-feature-when-using-iqueryable-foreach-and-mul

I have a similar problem but in my case the correspondance to the filter list is a List of IQueryables of int's and I get the same type of problem. In my case, though, I cannot find a way to perform the correspondence to the solution given by Justice. In my case the resulting parameterIds become an intersection of identical query results (i.e. the last one in the foreach loop) which of course result in the last result itself.

To be more explicit: here is a part of the code:

IQueryable<int> ParameterIds = ( Enumerable.Empty<int>( ) ).AsQueryable<int>( );
List<IQueryable<int>> TagIds = this.tags.Select( s => s.IDs ).ToList( );
bool firstTime = true;

foreach ( IQueryable<int> tags in TagIds) {
    IQueryable<int> c = (from tr in FlexiDataContext.dbTagRelations where tags.Any(s => s == tr.tag_parameter_id) select tr.parameter_id);
    if (firstTime)
    {
        ParameterIds =  c;
        firstTime = false;
    }
    else {
        ParameterIds = ParameterIds.Intersect( c );
    }
}
A: 

Oh, my mistake it does actually work. Sorry :-P

Tomas