I’m trying to get a somewhat basic LINQ query but can’t figure out all conditions. yrs could equal several years like “2009,2008,2007” or is could equal “%”, for a wildcard. This query works for “2009,2008,2007” but does not work for the wildcard. How can I make it work for both conditions?
var results = (from a in db.t_harvest_statistics
where yrs.Contains(a.year)
orderby a.id
select new { a.id, a.year, a.unit_number }).ToList();
Try this: