I have an asp.net mvc project where have the search filter form and 8 parameters which arrive from my form and must be null. Everything work fine when I populate all fields in my search form. But when I hold missing fields it returns all rows from the table. I have the next expression:
var model = repository.GetRows()
.Where(x => x.Var1 == Var1 || x.Var2 == Var2 ||
x.Var3 == Var3 || x.Var4 == Var4 ||
x.Var5 == Var5 || x.Var6 == Var6 ||
x.Var7 == Var7 || x.Var8 == Var8).ToList();
Have any trick for checking the null variables? Because I have to write a lot of if/else statement, which I think it's not right.
&&?