Where
returns an IEnumerable
, not a List
. Since you don't actually need your traces
variable to be an IList
here, you should type it as an IEnumerable
to avoid the needless overhead of populating the results of your query into a list just so that you can iterate over that list and populate a new list.
If it's important to materialize the results of the query into a list at some later point in time, after you have finished constructing the query, then you can call ToList
on the IEnumerable
to build up a List
with the results.
On top of the above, it appears that your actual data source is an IQueryable
representing a query against a database, not an in memory collection. You should use IQueryable
as the type of your variable. This will build up a query, rather than the results of the query, so that after building that query you can request the filtered results from your database, rather than pulling your entire database table into memory and filtering it there.