Linq to sql between List and Comma separated string
I Have one list and one comma separated column value.
lst.Add("Beau开发者_开发问答ty");
lst.Add("Services");
lst.Add("Others");
And Column value is like
Beauty,Services
Service,Others
Beauty,Others
Other,Services
Other
Beauty, Food
Food
Now I Want all those rows which contains any list item.
Output result is
Beauty,Services
Service,Others
Beauty,Others
Other,Services
Other
Beauty, Food
First Edit
These comma separated values are one of my table's one column value. I need to check against that column.
Assuming you can figure out how to get the RowCollection
RowCollection.Where(row => row.Split(",").ToList().Where(x => list.Contains(x)).Any()).ToList();
will evaluate to true if the row contains a value from the list.
try
List<string> lst = ....; // your list of strings
string[] somecolumnvalues = new string[] { "", "",... }; // your columvalues
var Result = from l in lst from c in somecolumnsvalues where c.Contains (l) select c;
精彩评论