I am trying to make a simple query which will search through my entity database and display all the reports and display all the reports with name "Fintan" . I am able to get the program to display all the the db but when I enter @if (line.name.Contains("Fintan")==true)
I get a nullReferenceException. Even tho there are reports with name= "Fintan"
View
@model DisplayViewModels
@foreach (var line in Model.Reports)
{
@if (line.name.Contains("Fintan")==true)
{
<h1>@line.name</h1>
}
}
Controller
public IActionResult SearchResults()
{
var displayViewModel = new DisplayViewModel
{
Reports = _reportRepository.AllReports
};
return View(displayViewModel); }
}