Using LINQ to SQL with a Comma-Separated Year List or Wildcard

I’m attempting a LINQ to SQL query where the year filter can either represent multiple specific years, like “2009,2008,2007”, or a wildcard symbol, “%”, to match any year. Currently, the query works when given a list of specific years but fails when using the wildcard. How can I modify the query to correctly handle both cases?

if (yearParam == "%") {
    var records = (from rec in db.harvestEntries
                   orderby rec.entryId
                   select new { rec.entryId, rec.year, rec.category }).ToList();
} else {
    var allowedYears = yearParam.Split(",");
    var records = (from rec in db.harvestEntries
                   where allowedYears.Contains(rec.year.ToString())
                   orderby rec.entryId
                   select new { rec.entryId, rec.year, rec.category }).ToList();
}

hey, try buildin u query dynamiclly. when yearParam is ‘%’, skip that filter. i had the same issue and ended up conditionally constructing my where clause. have u tried using alternative operators like .StartsWith? what do u think?