User1901201124 posted
Not sure if this belongs to the MVC forum as it may just be LINQ related. But if I have a search with a Checkbox (boolean type) IsClient , how do I exclude the where for IsClient if the checkbox is not check?
I can't do the below because the model.SearchIsCilent is a boolean type and there is no Null. But if it is not checked I want to return all results true or false.
I could do something like "model.SearchIsClient == true ? x.Client==true : (x.Client==true || x.Client=false)" but there must be a better way? I have multiple different checkboxes.
Hope that makes sense. Thanks
model.Users = db.Users
.Include(x => x.Address)
.Where(x => (model.SearchIsClient == null || x.Client == true))