The case I'll create is that I've got a lot of persons and a knows person get 0, 1 or multiple languages. The language can get 0, 1 or multiple MVPs. Inside the back office of Umbraco I've created two document types:
Person: with the first name, last name, photo and a (Obsolete) Multinode Treepicker for the known programming languages of that person.
Language: With the name and a piece of code.
The code
On the template of the language, I'll create a table with the language, the code sample and the MVPs.
For this I've create this code.
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ProgrammingLanguages>
@using EventCalendar.Website.Models;
@{
Layout = "Master.cshtml";
var searcher = ExamineManager.Instance.SearchProviderCollection["PersonsSearcher"];
var searchCriteria = searcher.CreateSearchCriteria();
var query = searchCriteria.Field("nodeTypeAlias", "person").Compile();
var persons = searcher.Search(query);
}
@Html.Partial("~/Views/Partials/SectionHeader.cshtml")
<table class="table">
<tr>
<th>Name</th>
<th>Output <samp>Hello World!</samp></th>
<th>MVP</th>
</tr>
@foreach (ProgrammingLanguage lang in Model.Content.Children)
{
var res = persons.Where(x => x.Fields["knowledge"] != null && x.Fields["knowledge"].Contains(lang.Id.ToString())); @* <-- instead of this *@
<tr>
<td>@lang.PageTitle</td>
<td><pre>@lang.HelloWorld</pre></td>
<td>
<ul>
@foreach (var r in res)
{
<li>@r.Fields["firstName"] @r.Fields["lastName"]</li>
}
</ul>
</td>
</tr>
}
</table>
This outputs this:
Good to know
I've created an indexer and a searcher for the persons.
After building:
My questions
Is this code performance enough?
Can I use typed persons? I'll like to use this code below instead of the marked line.
var res = persons.Where(x => x.Knowledge != null && x.Knowledge.Contains(lang)));
Get typed results for examine indexer using Umbraco
Continueing on this question on this forum Get typed document from an index using Umbraco 7.7, I've found a working solution.
The case
The case I'll create is that I've got a lot of persons and a knows person get 0, 1 or multiple languages. The language can get 0, 1 or multiple MVPs. Inside the back office of Umbraco I've created two document types:
Person
: with the first name, last name, photo and a (Obsolete) Multinode Treepicker for the known programming languages of that person.Language
: With the name and a piece of code.The code
On the template of the language, I'll create a table with the language, the code sample and the MVPs.
For this I've create this code.
This outputs this:
Good to know
I've created an indexer and a searcher for the persons.
After building:
My questions
Can I use typed persons? I'll like to use this code below instead of the marked line.
is working on a reply...