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

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -