Yes, it is. Generally, IQueryable<T>
implies that you are using a data source provider which is queried each time the queryable is enumerated (of course, this isn't always the case, as you can call AsQueryable extension method on an IEnumerable<T>
which will give you an IQueryable<T>
implementation over the IEnumerable<T>
implementation).
To that end, storing the IQueryable<Results>
in a dictionary doesn't actually prevent any hits to the data source when you enumerate through it a second time. It will make a request to the data provider every time you enumerate through it.
Because of this, you typically want to materialize the results on the client side, usually calling the ToList or ToArray extension methods, and then using IEnumerable<Results>
or Results[]
as the TValue type parameter of your dictionary.
Note that you could use a HashSet<T>
to store your objects, but you have to make sure that you implement IEquatable<T>
and override GetHashCode so that the default equality comparer will perform a comparison on the ID instance exposed by the Results type, either that, or you have to provide an IEqualityComparer<T>
implementation that will do the same thing. It's more than likely that you are using designer-generated code, and it will not do this for you, and your objects will have equality determined by reference, not by value.