Sometime you may want to know if a index exists on a certain field. You can use the db4o-meta information to find out if a field is indexed.
IStoredClass metaInfo = container.Ext().StoredClass(typeof(IndexedClass));
// list a fields and check if they have a index
foreach (IStoredField field in metaInfo.GetStoredFields())
{
if (field.HasIndex())
{
Console.WriteLine("The field '" + field.GetName() + "' is indexed");
}
else
{
Console.WriteLine("The field '" + field.GetName() + "' isn't indexed");
}
}
Dim metaInfo As IStoredClass = container.Ext().StoredClass(GetType(IndexedClass))
' list a fields and check if they have a index
For Each field As IStoredField In metaInfo.GetStoredFields()
If field.HasIndex() Then
Console.WriteLine("The field '" & field.GetName() & "' is indexed")
Else
Console.WriteLine("The field '" & field.GetName() & "' isn't indexed")
End If