3
My code has the following structure:
var a = ViewData["a"];
var b = ViewData["b"];
var c = ViewData["c"];
var d = ViewData["d"]:
foreach(var x in ObjetoE).where(x=> x.A == a && x.B == b && x.C == c && x.D == d){
// Faz alguma ação
}
In case, man ObjetoE
would be more or less like this:
public class ObjetoE
{
public string A { get; set; }
public string B { get; set; }
public string C { get; set; }
public string D { get; set; }
}
What happens is that the values defined for the variables a
,b
,c
and d
are dynamically assigned, in this case, by the ViewData
, may be null.
In this case what I would like to understand is if there is something that could take all if a variable is null, like a *
of a query
. Because it is impossible to work as conditionals validating whether the variable is null and generating several foreach
the basis of each condition.
The problem seems to be interesting, but I do not understand what you are wanting. Maybe it is purposeful but this code does not make sense.
– Maniero
@I edited it, now it might make a little more sense. But basically my question boils down to the fact that I need to have X options in my lambda, but some may come null and the same should be ignored. I have no intention to check condition and apply various foreach validating whether the input variables are null
– Rafael Barbosa