Siaqodb supports indexes for fields and/or automatic properties of primitive/basic types. Indexes ensures very fast retrieval for any given key: O(log n).

There are two ways to define and index:

1.by decorating the field or/and Automatic Property with the Index attribute :

public class Employee
{
    public string FirstName { get; set; }
    public string LastName { get; set; }

    [Index]
    DateTime hireDate;
    public DateTime HireDate
    {
        get { return hireDate; }
        set { hireDate = value; }
    }

    public int OID { get;set; }
    [Index]
    public int Age { get; set; }

}

The Age property is indexed and so is the hireDate field.

2.by adding indexes through SiaqodbConfigurator:

SiaqodbConfigurator.AddIndex("hireDate", typeof(Employee));
SiaqodbConfigurator.AddIndex("Age", typeof(Employee));

Indexes are detected automatically by Siaqodb's query engine. Once an index is defined, you don't have to do anything special to take advantage of it. For example, the query in the following example uses an indexed field for its where clause and so it will be very fast:

var q = from Employee emp in siaqodb
where emp.Age > 30
select emp;

Index values do not need to be unique and can accept multiple keys with the same value. Unique index values can be enforced by using the UniqueConstraint attribute, for example:

public class Employee
{
.....
    [Index]
    [UniqueConstraint]
    public Guid InternalID { get; set; }

}

All Employee instances will have Unique values for the indexed InternalID property.

Important: An Index is valid only if it is added to a field and/or to an automatic property. If you have a property with a backing field, be sure you put the index on the field and not on the Property, like in above examples.