Let's display the data that we inserted in our tables. We create a view where we will have the following code.
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using ComputerMagic.PetaPoco.Models
@using ComputerMagic.PetaPoco.Repository
@{
Layout = null;
}
<ul>
@foreach (var Author in Authors.GetAll())
{
<li>
@Author.Name @Author.Surname
<ul>
@foreach (var Book in Books.GetAllByAuthorID(Author.AuthorID))
{
<li>@Book.Title</li>
}
</ul>
</li>
}
</ul>
The output of this code will be the following.
<ul>
<li>
Douglas Adams
<ul>
<li>Dirk Gently's Holistic Detective Agency</li>
<li>The Hitchhiker's Guide to the Galaxy</li>
</ul>
</li>
<li>
Jules Verne
<ul>
<li>Around the World in Eighty Days</li>
<li>Journey to the Center of the Earth</li>
<li>Twenty Thousand Leagues Under the Sea</li>
</ul>
</li>
</ul>
The optical output on the web browser will be the following.