Note: This documentation is preliminary and is subject to change.
Defines an index on a type, providing direct access to objects based on the values of certain selected fields.
or
or
<Index> element defines the index on the type, providing direct access to objects based on the values of the selected propertys. The max-number-of-objects can be used to specify the maximum number of presistent objects with the same index value. Setting the max-number-of-objects as 1 declares the index to be a unique index.
Genome can use indexes to improve performance of queries that use indexed properties in their filter criteria.
Employee.cs
public abstract class Employee : Persistent {
...
public abstract Car Car { get; set; }
}
public abstract class Car {
...
public abstract Employee AssignedTo { get; }
return (Employee)DataDomain.Select(
"extentof(Northwind.Business.Employee)[e: e.Car == this].ToObject() " +
"with(IndexUsage="Car", Index_Car=[{0}])",
this).ToObject();
}
}
Northwind.xml
<Mapping xmlns="urn:TechTalk:TT.OODAL.XmlMapping">
...
<Type name="Employee">
<!-- indexes the FirstName property of the Employee -->
<Member name="FirstName" PersistentField="FN" Index="IdxFirstName" />
<!-- creates a unique index to the Car property to make the back-reference
on the Employee-Car one-one relation faster -->
<Member name="Car">
<NearObjectReference />
<Index name="IdxCar" maxFill="1" />
</Member>
</Type>
<Type name="Car">
<Member name="AssignedTo"
Oql='extentof(Employee)[e: e.Car == this].ToObject()
with(IndexUsage="IdxCar", Index_Car=[this])' />
</Type>
</Mapping>
// this function searches for the employee having a specified car
public static Employee GetEmployeeByCar(Car car) {
return (Employee)DataDomain.Select(
"extentof(Northwind.Business.Employee)[e: e.Car == {0}].ToObject() " +
"with(IndexUsage="IdxCar", Index_Car=[{0}])",
this).ToObject();
}
// returns the set of employees having the specified first name
public static Set GetEmployeesByFirstName(string fistName) {
return DataDomain.Select(
"extentof(Northwind.Business.Employee)[e: e.FirstName == {0}].ToObject() " +
"with(IndexUsage="IdxFirstName", Index_FirstName=[{0}])",
firstName);
}
Type: TechTalk.Genome.Mapping.IndexXmlData
Assembly: TechTalk.Genome.dll
Version: 4.2.4
Editions: Professional, Evaluation, Express
Database Platforms: Microsoft SQL Server 2000, Microsoft SQL Server 2005, Oracle 9i Release 2, Oracle 10g Release 2
Usage of Indices | Other Elements