c# - linq to sql query with checkboxes where condition combination -
if checkbox chkaus checked :
if (chkaus.checked) { vadvancesearchresults = (from t in vadvancesearchresults join imp in _bdatacontext.imprints on t.imprintid equals imp.id join cc in _bdatacontext.countrycodes on imp.countryid equals cc.id cc.code.contains("au") select t).distinct();** }
if chkaus , chknz checked
if (chknz.checked && chkaus.checked) { vadvancesearchresults = (from t in vadvancesearchresults join imp in _bdatacontext.imprints on t.imprintid equals imp.id join cc in _bdatacontext.countrycodes on imp.countryid equals cc.id cc.code.contains("au") || cc.code.contains("nz") select t).distinct(); }
the condition on linq query changes checkboxes checked.
where cc.code.contains("au") || cc.code.contains("nz")
i have 10 checkboxes, , got stuck on how write many conditions. please.
for example if there chkus : combination chkaus,chknz,chkus checkboxes linq query change.
where cc.code.contains("au") || cc.code.contains("nz") || cc.code.contains("us")
put of them in list , if list.contains(cc.code)
var = new list<string>(){"au","nz","us"}; var linq = (from t in vadvancesearchresults join imp in _bdatacontext.imprints on t.imprintid equals imp.id join cc in _bdatacontext.countrycodes on imp.countryid equals cc.id a.contains(cc.code) select t).distinct();
Comments
Post a Comment