How to search for a value which is comma separated in database through linq. My scenario is user can select Multiple value from listbox and then search those item in comma separated field in database.
I select two items so the value will be 2,3 and database field have values
1,2,4,5
1,4,3,6
2,3,4,5
1,4
The selected records must be record no 1 because it has 2, record no 2 because it has 3 and record no 3 because it has both and reject record no 4.
What i try is
string Commodites = "2,3";
obj.Where(e => Commodites.Contains(e.Id)).Distinct()
but it select only those record which have value 2,3 only
For CSV splitting I advise you to use any CSV parser, not simply use
string.Splitmethod.