Additional index structures can be created for the tables. There are multiple types of index structures (and developers are allowed to create their own), so an index factory instance has to be specified. The indexed fields are set with a lambda expression. The following example shows how to create an index on the group foreign key of the Person entity.

public class MyDatabase : Database
{
    public MyDatabase()
    {
        var peopleTable = base.Tables.Create<Person, int>(p => p.Id);

        var peopleGroupIdIndex = peopleTable.CreateIndex(
            new RedBlackTreeIndexFactory<Person>(), 
            p => p.GroupId);

        this.People = peopleTable;
    }

    public ITable<Person> People { get; private set; }
}

Last edited Jun 10, 2012 at 6:28 PM by tamasflamich, version 4

Comments

Mario_1 Jul 17, 2014 at 7:56 AM 
Hi, how to create an index on multiple fields, e.g. Name and BirthDay of the Person entity?