NPersistence Reference Guide
 

Types

      
 All Types  Classes  
 NameDescription
Index
Specifies that an index should be placed on the column or group of columns.

Examples

CopyC#
Example 1:
2 different indices for the 2 columns
[Index]
public String getName() { return name; }

[Index]
public String getDescription() { return description; }

Example 2:
Both columns included in one index.
[Index(Name="ix1")]
public String getName() { return name; }

[Index(Name="ix1")]
public String getDescription() { return description; }

Example 3:
The Index annotation is defined at the Entity level
[Index(Name="ix1", Members=new String[]{"name", "description"})]
[Entity]
public class Person
...
public String getName() { return name; }
public String getDescription() { return description; }
Unique
Specifies that a unique constraint should be placed on the column or group of columns.

Examples

CopyC#
Example 1:
2 different unique constraints for the 2 columns
[Unique]
public String getName() { return name; }

[Unique]
public String getDescription() { return description; }

Example 2:
Both columns included in one unique constraint.
[Unique(Name="uq1")]
public String getName() { return name; }

[Unique(Name="uq1")]
public String getDescription() { return description; }

Example 3:
The Unique annotation is defined at the Entity level
[Unique(Name="ix1", Members=new String[]{"name", "description"})]
[Entity]
public class Person
...
public String getName() { return name; }
public String getDescription() { return description; }