Find csv data in column from list of data via linq -
my column in table stores csv list of items. in c# have list of items , want linq query on column returning rows have of items in list.
table defined as
name|tags
with example data of
joe | football,soccer,basketball mike | hockey,soccer steve | basketball,baseball
so if c# list contains soccer , basketball joe , steve since both have 1 of in tags list.
note, i'm using entity framework table.
you have bring entity data memory:
var result = players.tolist() .where(item => item.tags.split(',').any(x => x.contains("basketball") || x.contains("baseball"));
should give 2 results.
update: providing list of sports
list<string> sports = new list<string> { "baseball", "basketball", "football" }; var result = players.tolist() .where(item => item.tags.split(',').any(sports.contains));
Comments
Post a Comment