now I can not get the correct information
List<HeaderHelper> h = pr.Actual_View();
foreach (TemplateHeader t in pr.TemplateView())
{
var v= h.Where(z => z.Country == t.Pais
&& z.dia == t.diaTotal
&& z.Segment == t.Segmento).FirstOrDefault();
}
The
pr.Actual_View()
is a class method for a list containing the following fields:
- Country (string)
- dia (int)
- Segment (string)
The
pr.TemplateView()
is a class method for list containing the same fields and same datatype
the list t may contain more information than the list h, so I need to filter the list h with several criteria, but when I run the code does not correctly filter the list, returning a null.
If
vis null, that suggests that none of the values intmatched yourWhereclause, soFirstOrDefaultreturned the default value ofTemplateHeader, which is null.Without more information or sample data we’ve got absolutely no way of knowing why none of the values in
tmatched, but that’s what the null value ofvindicates.