I am trying to load each staff members holiday record but I am unable to populate holiday records.
Here is the code from my controller:
public class HomeController : Controller
{
private HRModel.db_HRSystemModel db = new HRModel.db_HRSystemModel();
public IActionResult Index()
{
var staff = (from s in db.Hrstaffpersonaldetails
where s.Firstname == "Ian"
select s).ToList();
return View(staff);
}
}
and here is the code from my view:
<div>
<h4>Staff</h4>
<hr />
@foreach (var s in Model)
{
<dl class="dl-horizontal">
<dt>
First Name:
</dt>
<dd>
@s.Firstname
</dd>
<dt>
Surname:
</dt>
<dd>
@s.Surname
</dd>
<dt>
Username:
</dt>
<dd>
@s.Username
</dd>
@foreach (var hr in s.Hrstaffholidayrecords)
{
<dt>
date:
</dt>
<dd>
@hr.Startdate
</dd>
}
</dl>
}
</div>
When I currently run what I have (on .NET Core 1.1), holiday records returns 0 records from the database. I'm not really sure if I'm missing something or I'm doing it wrong.
Thanks, Ian