Skip to content
This repository has been archived by the owner on Nov 3, 2018. It is now read-only.

Temporal Relationship Tr:Nt

mj1856 edited this page Jan 26, 2013 · 2 revisions

This is an example of an index with a Tr:NT relationship. All revisions of employees are indexed by their name and department name.

public class Employees_ByDepartment : AbstractIndexCreationTask<Employee, EmployeeWithDepartment>
{
    public Employees_ByDepartment()
    {
        Map = employees => 
        
        from employee in employees
        let department = LoadDocument<Department>(employee.DepartmentId)
        select new
        {
           employee.Name,
           Department = department.Name
        };

        // The department field is stored so we can return it in a projection.
        Store(x => x.Department, FieldStorage.Yes);
    }
}