I have these 4 checkboxes, which constitute the string variables saljes, kopes, bytes, erbjudes. When they are checked they get the value "on".
From this I put together a string variable (p) that contains all the numbers I want to include in the LINQ-statement. Let say if all the checkboxes are checked, i would get a string that is "1234", and if only checkbox 2 and 4 are checked, it would result in "24".
In my database I have a field called "Type" which is of type int. I want to tell the database to include all the rows that have a "Type" value that can be found in the string p.
Something like this (of course my code doesn't work, therefore I need you guys):
var searchResult = from s in db.Ads select s;
string p = "1";
if (saljes != "on")
p = p.Replace("1", "");
if (kopes == "on")
p += "2";
if (bytes == "on")
p += "3";
if (erbjudes == "on")
p += "4";
searchResult = searchResult.Where(s => p.Contains(s => s.Type.ToString());
What I kinda need to do is a reversed Contains(), but how?