Reputation: 749
I'm trying to get this LINQ to SQL to work. The problem is parsedSeasons is a string like "1,2,3" and h.season is an int column. How can I get this to work correctly?
var id = (from h in db.t_ref_harvest_type
where parsedSeasons.Contains(h.season)
select new { h.id });
Upvotes: 1
Views: 2321
Reputation: 4524
You need to first split your comma delimited string like this:
var Seasons = parsedSeasons.Split(',').Select(int.Parse);
Then use your LINQ query:
var id = (from h in db.t_ref_harvest_type
where Seasons.Contains(h.season)
select new { h.id });
Upvotes: 1